Tuesday, July 21, 2015

Re: I cannot realise a :map why ??

On 21.07.15 01:02, aubertin.sylvain wrote:
> For instance I should like to make F9 stand for papa
> Following VIM Manual (by Moolenaar) I type :
> :map <F9> ipapa<Esc> (5 characters for <Esc> and 4 characters for <F5> )

That works for me, when typed on Vim's command line, omitting your
bracketed comment. In .vimrc there'd be no leading ':'.

Does a ":map" show that your new mapping has been accepted?
If so, I'd try another key - not a function key.
If the mapping was not accepted, and there was no error message, then I
think there would be a raising of eyebrows, and some action.

I do notice at :h :map-special-keys
"The <> form cannot be used when 'cpoptions' includes the '<' flag."
so what does ":set cpoptions ?" show?

Having "paste" set would inhibit the mapping in insert mode, but the
mapping makes clear that you intend to use it in normal mode.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Presumably your tests were conducted in normal mode, but a leading <Esc>
covers mode forgetfulness, and a "noremap" is good form:

:noremap <F9> <Esc>ipapa<Esc>

If we're not there yet, maybe try another case, to gather information:

:noremap <F1> :set nornu<CR> " Clear relative line numbering.

:set rnu " Set relative line numbering.

Then press <F1>. The numbers should go away again.

Even if your <F9> had been mapped to something else, the new mapping
would replace that.

As an aside, interestingly, I read:

>>> *map-comments*
It is not possible to put a comment after these commands, because the '"'
character is considered to be part of the {lhs} or {rhs}.
<<<

And yet I have no problem with this in my .vimrc:

" For vimdiff:
noremap <F10> :diffput<CR>]c " Copy first -> second file, next change.
noremap <F9> :diffget<CR>]c " Copy first <- second file, next change.

Erik

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: