Saturday, February 19, 2011

Re: mapping F3 to map q ^B

Reply to message «mapping F3 to map q ^B»,
sent 00:23:31 20 February 2011, Sunday
by lylez:

> I have
>
> map #2 ^[:unmap q^M
>
> which works
>
> and
>
> map #3 ^[:map q ^B^M
>
> which does not produce any errors, but doesn't work. Pressing F3 causes vim
> to display "No mapping found".
What do you actually have in place of `#2' and `#3'? You should have <F2> and
<F3> to map this keys, so try the following commands:

noremap <F2> <Esc>:unmap q<CR>
noremap <F3> <Esc>:noremap q <C-b><CR>

You can even combine it into one toggler:

noremap <F2> <Esc>:if !empty(maparg('q')) \| unmap q \| else \| noremap q
<C-b> \|
endif<CR>

> I suspect my problem is that I'm trying to do a mapping with a map command
> (something akin to trying to print a double quote inside of a double-quoted
> string).
No, this assumption is wrong, there is nothing special of using :map
inside a map, problems of such type will only occur if you try
to redefine or undefine some non-anonymous function while this function
is running.

Original message:
> Hello
>
> To make paging easier, I have in my .vimrc
>
> map q ^B
> map g ^F
>
> Some times I want to use the recording feature activated by qq, so I want
> to undo the mapping of q, then restore it afterwards.
>
> I have
>
> map #2 ^[:unmap q^M
>
> which works
>
> and
>
> map #3 ^[:map q ^B^M
>
> which does not produce any errors, but doesn't work. Pressing F3 causes vim
> to display "No mapping found".
>
> I suspect my problem is that I'm trying to do a mapping with a map command
> (something akin to trying to print a double quote inside of a double-quoted
> string).
>
> Any ideas?
>
> thanks
>
> Lyle

No comments: