|
|
| Line 14: |
Line 14: |
| |
I personally find it very awkward and unintuitive 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. |
|
I personally find it very awkward and unintuitive 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. |
+ |
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: |
|
Just create file $VIMRUNTIME/ftplugin/help.vim with following contens: |
| Line 25: |
Line 25: |
| |
|
|
|
| |
" map ctrl-] to enter in normal mode only for this buffer |
|
" map ctrl-] to enter in normal mode only for this buffer |
| − |
nnoremap <buffer><cr> <c-]> |
+ |
nnoremap <buffer><CR> <c-]> |
| |
|
|
|
| |
" map ctrl-T to backspace in normal mode only for this buffer |
|
" map ctrl-T to backspace in normal mode only for this buffer |
| − |
nnoremap <buffer><bs> <c-T> |
+ |
nnoremap <buffer><BS> <c-T> |
| |
</pre> |
|
</pre> |
| |
|
|
|
| Line 34: |
Line 34: |
| |
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. |
|
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.) |
+ |
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.) |
| |
|
|
|
| |
---- |
|
---- |
| |
Very useful mappings for helpfiles. I've added them to my help.vim, which also contains these for navigating from |label| to |label|: |
|
Very useful mappings for helpfiles. I've added them to my help.vim, which also contains these for navigating from |label| to |label|: |
| |
<pre> |
|
<pre> |
| − |
nnoremap <buffer> <Tab> /<Bar>\k*<Bar><CR> |
+ |
nnoremap <buffer> <Tab> /<Bar>\k*<Bar><CR> |
| − |
nnoremap <buffer> <S-Tab> ?<Bar>\k*<Bar><CR> |
+ |
nnoremap <buffer> <S-Tab> ?<Bar>\k*<Bar><CR> |
| |
" Can't get s-tab to work in xterm, so... |
|
" Can't get s-tab to work in xterm, so... |
| − |
nmap <buffer> . <Tab> |
+ |
nmap <buffer> . <Tab> |
| − |
nmap <buffer> , <S-Tab> |
+ |
nmap <buffer> , <S-Tab> |
| |
</pre> |
|
</pre> |
| |
|
|
|
| Line 49: |
Line 49: |
| |
I couldn't get it working by using the help.vim file. Adding these lines to .vimrc seems to work though: |
|
I couldn't get it working by using the help.vim file. Adding these lines to .vimrc seems to work though: |
| |
<pre> |
|
<pre> |
| − |
:au filetype help :nnoremap <buffer><cr> <c-]> |
+ |
:au filetype help :nnoremap <buffer><CR> <c-]> |
| − |
:au filetype help :nnoremap <buffer><bs> <c-T> |
+ |
:au filetype help :nnoremap <buffer><BS> <c-T> |
| |
</pre> |
|
</pre> |
| |
|
|
|
| Line 56: |
Line 56: |
| |
To avoid display of '|' when using goulding(princeton.edu) mappings above, use theese instead: |
|
To avoid display of '|' when using goulding(princeton.edu) mappings above, use theese instead: |
| |
<pre> |
|
<pre> |
| − |
nnoremap <buffer> <Tab> /<Bar>\zs\k*\ze<Bar><CR> |
+ |
nnoremap <buffer> <Tab> /<Bar>\zs\k*\ze<Bar><CR> |
| − |
nnoremap <buffer> <S-Tab> ?<Bar>\zs\k*\ze<Bar><CR> |
+ |
nnoremap <buffer> <S-Tab> ?<Bar>\zs\k*\ze<Bar><CR> |
| |
</pre> |
|
</pre> |
| |
|
|
|
| Line 65: |
Line 65: |
| |
Here is my ~/.vim/after/ftplugin/help.vim and ~/.vim/after/ftplugin/man.vim (same content): |
|
Here is my ~/.vim/after/ftplugin/help.vim and ~/.vim/after/ftplugin/man.vim (same content): |
| |
<pre> |
|
<pre> |
| − |
" Browse just with <CR>/<BS> |
+ |
" Browse just with <CR>/<BS> |
| − |
" We allow remapping of <C-]> as ftplugin/man.vim remaps it |
+ |
" We allow remapping of <C-]> as ftplugin/man.vim remaps it |
| − |
nmap <buffer><CR> <C-]> |
+ |
nmap <buffer><CR> <C-]> |
| − |
nnoremap <buffer><BS> <C-T> |
+ |
nnoremap <buffer><BS> <C-T> |
| − |
if &filetype == 'help' |
+ |
if &filetype == 'help' |
| − |
" Lookup |label| using <Tab>/<S-Tab> |
+ |
" Lookup |label| using <Tab>/<S-Tab> |
| − |
nnoremap <buffer> <Tab> /<Bar>\zs\k*\ze<Bar><CR> |
+ |
nnoremap <buffer> <Tab> /<Bar>\zs\k*\ze<Bar><CR> |
| − |
nnoremap <buffer> <S-Tab> ?<Bar>\zs\k*\ze<Bar><CR> |
+ |
nnoremap <buffer> <S-Tab> ?<Bar>\zs\k*\ze<Bar><CR> |
| |
endif |
|
endif |
| |
</pre> |
|
</pre> |
I personally find it very awkward and unintuitive 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:
" 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>
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.)
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>
I couldn't get it working by using the help.vim file. Adding these lines to .vimrc seems to work though:
:au filetype help :nnoremap <buffer><CR> <c-]>
:au filetype help :nnoremap <buffer><BS> <c-T>
To avoid display of '|' when using goulding(princeton.edu) mappings above, use theese instead:
nnoremap <buffer> <Tab> /<Bar>\zs\k*\ze<Bar><CR>
nnoremap <buffer> <S-Tab> ?<Bar>\zs\k*\ze<Bar><CR>
Also, don't put your mappings in $VIMRUNTIME/ftplugin/help.vim but instead in $HOME/{.vim|vimfiles}/after/ftplugin/help.vim (without the didftplugin check), as this will not completely override any ftplugin settings set by the Vim distribution either in this version or a next upgrade.
Here is my ~/.vim/after/ftplugin/help.vim and ~/.vim/after/ftplugin/man.vim (same content):
" Browse just with <CR>/<BS>
" We allow remapping of <C-]> as ftplugin/man.vim remaps it
nmap <buffer><CR> <C-]>
nnoremap <buffer><BS> <C-T>
if &filetype == 'help'
" Lookup |label| using <Tab>/<S-Tab>
nnoremap <buffer> <Tab> /<Bar>\zs\k*\ze<Bar><CR>
nnoremap <buffer> <S-Tab> ?<Bar>\zs\k*\ze<Bar><CR>
endif