Monday, August 28, 2017

Re: Evoking the option for :help in a mapping

Am 28.08.2017 um 19:02 schrieb Graham Lawrence:
> I have the customary mappings for :help,
>
> nmap <F1> :exec "help " . expand("<cword>")<CR>
> nmap <S-F1> :exec "help " . expand("<cWORD>")<CR>
>
> and have been trying to develop similar do the <Tab> option on the cursor
> word, something like
>
> nmap \\ yiw:h ^R"^[

But ^[ means Escape, not Tab,
and Escape, when used in a mapping, works like Enter (usually):
:h c_Esc

So you want <Tab> (right?) which looks more like ^I, but anyway in a mapping you can't use <Tab>,
instead you need to use the key defined with
:h 'wildcharm
(:set wcm=<C-_> works for me).

> but to no avail. Although the mapping does not terminate with a <CR>, vim
> treats the ^[ as if it were <CR> rather than <Tab> and goes straight to the
> specific help for the cursor-word.
>
> Is it possible to have vim act on the <Tab> as it does in the command line?

Your mapping becomes (with above 'wcm' setting):
:nnoremap \\ yiw:h <C-R>"<C-_>

or
:nnoremap \\ :<C-U>h <C-R><C-W><C-_>

or (I think I'd use)
:nnoremap <Leader><Tab> :<C-U>h <C-R><C-W><C-_>

--
Andy

--
--
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:

Post a Comment