Evoking the <Tab> option for :help in a mapping

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Evoking the <Tab> option for :help in a mapping

porphyry5
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 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?

--
Graham Lawrence

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Evoking the <Tab> option for :help in a mapping

'Jürgen Krämer' via vim_use
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Evoking the <Tab> option for :help in a mapping

Tony Mechelynck
In reply to this post by porphyry5
On Mon, Aug 28, 2017 at 7:02 PM, Graham Lawrence <[hidden email]> wrote:

> 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 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?
>
> --
> Graham Lawrence

See :help 'wildcharm'

For instance:

    if has('wildmenu')
        set wildmenu wildmode=longest:full,full wildcharm=<C-Z>
        map <F1> <expr> ':help ' . expand('cword') . "\<C-Z>"
        map <S-F1> <expr> ':help ' . expand('cWORD') . "\<C-Z>"
    endif

See also
    :help map-<expr>
    :help expr-quote

Best regards,
Tony.

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Evoking the <Tab> option for :help in a mapping

porphyry5
On Monday, August 28, 2017 at 1:32:32 PM UTC-7, Tony Mechelynck wrote:

> On Mon, Aug 28, 2017 at 7:02 PM, Graham Lawrence <[hidden email]> wrote:
> > 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 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?
> >
> > --
> > Graham Lawrence
>
> See :help 'wildcharm'
>
> For instance:
>
>     if has('wildmenu')
>         set wildmenu wildmode=longest:full,full wildcharm=<C-Z>
>         map <F1> <expr> ':help ' . expand('cword') . "\<C-Z>"
>         map <S-F1> <expr> ':help ' . expand('cWORD') . "\<C-Z>"
>     endif
>
> See also
>     :help map-<expr>
>     :help expr-quote
>
> Best regards,
> Tony.

Thank you both, Andy and Tony, for referring me to wildcharm/wildmenu.  Just the ticket.

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.