Vim logo vim online Vim Book Ad

basic Tip #397: mapping for better browsing of :help docs

 tip karma   Rating 17/8, Viewed by 319 

created:   January 9, 2003 23:01      complexity:   basic
author:   Stanislav Sitar      as of Vim:   6.0

I personally find it very akward and un-intuitive to browse the documentation
using Ctrl-] for following the link and Ctrl-Shift-t to go back.

I have had an idea to to remap those commands to Enter and Backspace, since
I do not use those keys in help in normal mode.

The command :nnoremap <buffer> can remap the key only in the given buffer
without affecting the other buffers.

just create file
$VIMRUNTIME/ftplugin/help.vim

with following contens
""""""""""""""""""""""""""""""""""""""""""""""""
"""" begining of the file

" Only do this when not done yet for this buffer
if exists("b:did_ftplugin")
  finish
endif

" map ctrl-] to enter in normal mode only for this buffer
nnoremap <buffer><cr> <c-]>

" map ctrl-T to backspace in normal mode only for this buffer
nnoremap <buffer><bs> <c-T>

"""" End of the file
""""""""""""""""""""""""""""""""""""""""""""""""

 rate this tip  Life Changing Helpful Unfulfilling 

<<Highlighting whitespaces at end of line | Mapping for quicker access to macros >>

Additional Notes

[email protected], January 10, 2003 8:41
You can adapt this to also use it with the man page file type, so you can hit return on a ref to another man page etc.

I had to use the after config file "~/.vim/after/ftplugin/man.vim" and nmap instead of nnoremap to getting it working. (I think this is because the default man.vim needs to set its remap of <c-]> first.)
[email protected], January 10, 2003 21:22
Very useful mappings for helpfiles.  I've added them to my help.vim, which also contains these for navigating from |label| to |label|:

nnoremap <buffer> <Tab> /<Bar>\k*<Bar><CR>
nnoremap <buffer> <S-Tab> ?<Bar>\k*<Bar><CR>
" Can't get s-tab to work in xterm, so...
nmap <buffer> . <Tab>
nmap <buffer> , <S-Tab>
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to [email protected] after searching the archive. Help Bram help Uganda.
SourceForge Logo