Sunday, February 20, 2011

Re: mapping F3 to map q ^B

Reply to message «Re: mapping F3 to map q ^B»,
sent 03:18:13 20 February 2011, Sunday
by lylez:

> But that didn't. I still get the "No mapping found" message when I press
> F3.
The answer was given by Ben Schmidt: I forgot that <C-b> means something in
cmdline mode, so you need to escape it: replace <C-b> with <LT>C-b> as he
suggested.

> I'm afraid that didn't work either. It says:
>
> E492: Not an editor command: endifif !empty(maparg('q')) | unmap q |
>
> I copied and pasted it directly. I do note that the error message mentions
> an endifif, even though what you typed was "endif".
That command should be written in one line. Maybe this is the problem if your
client added some unneeded line breaks. Try the following:

function s:ToggleQ()
if !empty(maparg('q', 'n'))
unmap q
else
noremap q <C-b>
endif
return ""
endfunction
noremap <expr> <F2> <SID>ToggleQ()

Original message:
> > What do you actually have in place of `#2' and `#3'?
>
> That's actually what I have. I use this technique for other function keys
> and it's always worked.
>
> > You should have <F2> and
> >
> > <F3> to map this keys, so try the following commands:
> > noremap <F2> <Esc>:unmap q<CR>
>
> That part worked...
>
> > noremap <F3> <Esc>:noremap q <C-b><CR>
>
> But that didn't. I still get the "No mapping found" message when I press
> F3.
>
> > 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'm afraid that didn't work either. It says:
>
> E492: Not an editor command: endifif !empty(maparg('q')) | unmap q |
>
> I copied and pasted it directly. I do note that the error message mentions
> an endifif, even though what you typed was "endif".
>
> > *signature.asc* (205 bytes) Download
> > Attachment<http://attachment/3392740/0/signature.asc>
> >
> >
> > ------------------------------
> >
> > If you reply to this email, your message will be added to the discussion
> >
> > below:
> >
> > http://vim.1045645.n5.nabble.com/mapping-F3-to-map-q-B-tp3392648p3392740.
> > html
> >
> > To unsubscribe from mapping F3 to map q ^B, click
> > here<http://vim.1045645.n5.nabble.com/template/NamlServlet.jtp?macro=un
> > subscribe_by_code&node=3392648&code=bHlsZS56aWVnZWxtaWxsZXJAZ21haWwuY29t
> > fDMzOTI2NDh8LTE2NjY1MDgxOTA=>.

No comments:

Post a Comment