|
|
| Line 15: |
Line 15: |
| |
==Getting started== |
|
==Getting started== |
| |
Try these examples: |
|
Try these examples: |
| − |
*Enter <tt>:help</tt> to browse help. Scroll down the help page to see the quickref and tutor links, and the table of contents. |
+ |
*Enter <code>:help</code> to browse help. Scroll down the help page to see the quickref and tutor links, and the table of contents. |
| |
*Enter {{help|pattern}} for help on the topic ''pattern'' (for example). |
|
*Enter {{help|pattern}} for help on the topic ''pattern'' (for example). |
| − |
*<tt>:h pattern</tt> is the same (the <tt>:help</tt> command can be abbreviated). |
+ |
*<code>:h pattern</code> is the same (the <code>:help</code> command can be abbreviated). |
| |
|
|
|
| |
Command completion can be used when entering a help topic: |
|
Command completion can be used when entering a help topic: |
| − |
*Type <tt>:h patt</tt> then press Ctrl-D to list all topics that contain "<tt>patt</tt>". |
+ |
*Type <code>:h patt</code> then press Ctrl-D to list all topics that contain "<code>patt</code>". |
| − |
*Type <tt>:h patt</tt> then press Tab to scroll through the topics that start with "<tt>patt</tt>". |
+ |
*Type <code>:h patt</code> then press Tab to scroll through the topics that start with "<code>patt</code>". |
| − |
*If you have set the <tt>{{help|'wildmenu'|prefix=no}}</tt> option (e.g. by using <tt>:set wildmenu</tt>), then <tt>:h patt</tt> followed by <tt><Tab></tt> opens a menu on the statusline, with all help topics containing "<tt>patt</tt>". You can select any item in the menu with the arrow keys or more presses of the <tt><Tab></tt> key to fill in the rest of your command line. |
+ |
*If you have set the <code>{{help|'wildmenu'|prefix=no}}</code> option (e.g. by using <code>:set wildmenu</code>), then <code>:h patt</code> followed by <code><Tab></code> opens a menu on the statusline, with all help topics containing "<code>patt</code>". You can select any item in the menu with the arrow keys or more presses of the <code><Tab></code> key to fill in the rest of your command line. |
| |
|
|
|
| |
Links: |
|
Links: |
| − |
*Enter <tt>:h</tt> to open the main help page. |
+ |
*Enter <code>:h</code> to open the main help page. |
| − |
*Type <tt>/quick</tt> to search for "quick" (should find the <tt>quickref</tt> link). |
+ |
*Type <code>/quick</code> to search for "quick" (should find the <code>quickref</code> link). |
| |
*Press Ctrl-] to follow the link (jump to the quickref topic). |
|
*Press Ctrl-] to follow the link (jump to the quickref topic). |
| |
*After browsing the quickref topic, press Ctrl-T to go back to the previous topic. |
|
*After browsing the quickref topic, press Ctrl-T to go back to the previous topic. |
| Line 32: |
Line 32: |
| |
|
|
|
| |
Searching: |
|
Searching: |
| − |
*Search within a help file using <tt>/</tt> like you would when searching any file. |
+ |
*Search within a help file using <code>/</code> like you would when searching any file. |
| − |
*Search all the help files with the <tt>:helpgrep</tt> command, for example: |
+ |
*Search all the help files with the <code>:helpgrep</code> command, for example: |
| − |
::<tt>:helpgrep \csearch.\{,12}file</tt> |
+ |
::<code>:helpgrep \csearch.\{,12}file</code> |
| − |
::<tt>\c</tt> means the pattern is case insensitive. |
+ |
::<code>\c</code> means the pattern is case insensitive. |
| |
::The pattern finds "search" then up to 12 characters followed by "file". |
|
::The pattern finds "search" then up to 12 characters followed by "file". |
| |
:You will then see the first match. To see other matches for the same pattern, use: |
|
:You will then see the first match. To see other matches for the same pattern, use: |
| − |
::<tt>:cnext</tt> |
+ |
::<code>:cnext</code> |
| − |
::<tt>:cprev</tt> |
+ |
::<code>:cprev</code> |
| − |
::<tt>:cnfile</tt> |
+ |
::<code>:cnfile</code> |
| − |
::<tt>:cpfile</tt> |
+ |
::<code>:cpfile</code> |
| − |
::<tt>:cfirst</tt> |
+ |
::<code>:cfirst</code> |
| − |
::<tt>:clast</tt> |
+ |
::<code>:clast</code> |
| |
:and even |
|
:and even |
| − |
::<tt>:cc</tt> |
+ |
::<code>:cc</code> |
| |
:which brings you back to the current match after you scrolled the helpfile, or |
|
:which brings you back to the current match after you scrolled the helpfile, or |
| − |
::<tt>:copen</tt> |
+ |
::<code>:copen</code> |
| − |
:which will list out all the matches in a separate window. Read up on these commands with the <tt>:help</tt> entry for each of them! |
+ |
:which will list out all the matches in a separate window. Read up on these commands with the <code>:help</code> entry for each of them! |
| |
|
|
|
| − |
Each week (or more often if you prefer), read a new section from the <tt>:help</tt> page to learn something new! |
+ |
Each week (or more often if you prefer), read a new section from the <code>:help</code> page to learn something new! |
| |
|
|
|
| |
==Context== |
|
==Context== |
| Line 57: |
Line 57: |
| |
! style="width:4em" | Prefix !! style="width:8em" | Example !! Context |
|
! style="width:4em" | Prefix !! style="width:8em" | Example !! Context |
| |
|- |
|
|- |
| − |
|<tt>:</tt> || <tt>:h :r</tt> || ex command (command starting with a colon) |
+ |
|<code>:</code> || <code>:h :r</code> || ex command (command starting with a colon) |
| |
|- |
|
|- |
| − |
|''none'' || <tt>:h r</tt> || normal mode |
+ |
|''none'' || <code>:h r</code> || normal mode |
| |
|- |
|
|- |
| − |
|<tt>v_</tt> || <tt>:h v_r</tt> || visual mode |
+ |
|<code>v_</code> || <code>:h v_r</code> || visual mode |
| |
|- |
|
|- |
| − |
|<tt>i_</tt> || <tt>:h i_CTRL-W</tt> || insert mode |
+ |
|<code>i_</code> || <code>:h i_CTRL-W</code> || insert mode |
| |
|- |
|
|- |
| − |
|<tt>c_</tt> || <tt>:h c_CTRL-R</tt> || ex command line |
+ |
|<code>c_</code> || <code>:h c_CTRL-R</code> || ex command line |
| |
|- |
|
|- |
| − |
|<tt>/</tt> || <tt>:h /\r</tt> || search pattern (in this case, <tt>:h \r</tt> also works) |
+ |
|<code>/</code> || <code>:h /\r</code> || search pattern (in this case, <code>:h \r</code> also works) |
| |
|- |
|
|- |
| − |
|<tt>'</tt> || <tt>:h 'ro'</tt> || option |
+ |
|<code>'</code> || <code>:h 'ro'</code> || option |
| |
|- |
|
|- |
| − |
|<tt>-</tt> || <tt>:h -r</tt> || Vim argument (starting Vim) |
+ |
|<code>-</code> || <code>:h -r</code> || Vim argument (starting Vim) |
| |
|} |
|
|} |
| |
|
|
|
| − |
Sometimes you want to know what a particular control key means to Vim. For example, to see all help topics containing "ctrl-r", type <tt>:h ctrl-r</tt> then press Ctrl-D. The following examples show the help for pressing various keys in different contexts. |
+ |
Sometimes you want to know what a particular control key means to Vim. For example, to see all help topics containing "ctrl-r", type <code>:h ctrl-r</code> then press Ctrl-D. The following examples show the help for pressing various keys in different contexts. |
| |
{| class="cleartable" |
|
{| class="cleartable" |
| |
! style="width:8em" | Example !! Help for key |
|
! style="width:8em" | Example !! Help for key |
| |
|- |
|
|- |
| − |
|<tt>:h CTRL-R</tt> || Ctrl-R in normal mode |
+ |
|<code>:h CTRL-R</code> || Ctrl-R in normal mode |
| |
|- |
|
|- |
| − |
|<tt>:h i_CTRL-R</tt> || Ctrl-R in insert mode |
+ |
|<code>:h i_CTRL-R</code> || Ctrl-R in insert mode |
| |
|- |
|
|- |
| − |
|<tt>:h c_CTRL-R</tt> || Ctrl-R in command mode |
+ |
|<code>:h c_CTRL-R</code> || Ctrl-R in command mode |
| |
|- |
|
|- |
| − |
|<tt>:h v_CTRL-V</tt> || Ctrl-V in visual mode |
+ |
|<code>:h v_CTRL-V</code> || Ctrl-V in visual mode |
| |
|} |
|
|} |
| |
|
|
|
| Line 91: |
Line 91: |
| |
*Press Enter to jump to the subject (topic) under the cursor. |
|
*Press Enter to jump to the subject (topic) under the cursor. |
| |
*Press Backspace to return from the last jump. |
|
*Press Backspace to return from the last jump. |
| − |
*Press <tt>s</tt> to find the next subject, or <tt>S</tt> to find the previous subject. |
+ |
*Press <code>s</code> to find the next subject, or <code>S</code> to find the previous subject. |
| − |
*Press <tt>o</tt> to find the next option, or <tt>O</tt> to find the previous option. |
+ |
*Press <code>o</code> to find the next option, or <code>O</code> to find the previous option. |
| |
|
|
|
| − |
Create file <tt>~/.vim/ftplugin/help.vim</tt> (Unix) or <tt>$HOME/vimfiles/ftplugin/help.vim</tt> (Windows) containing: |
+ |
Create file <code>~/.vim/ftplugin/help.vim</code> (Unix) or <code>$HOME/vimfiles/ftplugin/help.vim</code> (Windows) containing: |
| |
<pre> |
|
<pre> |
| |
nnoremap <buffer> <CR> <C-]> |
|
nnoremap <buffer> <CR> <C-]> |
| Line 103: |
Line 103: |
| |
nnoremap <buffer> S ?\|\zs\S\+\ze\|<CR> |
|
nnoremap <buffer> S ?\|\zs\S\+\ze\|<CR> |
| |
</pre> |
|
</pre> |
| − |
The following mappings (which can go in your vimrc) simplify navigating the results of {{help|quickfix|prefix=no}} commands such as (among others) <tt>:helpgrep</tt> |
+ |
The following mappings (which can go in your vimrc) simplify navigating the results of {{help|quickfix|prefix=no}} commands such as (among others) <code>:helpgrep</code> |
| |
<pre> |
|
<pre> |
| |
:nnoremap <S-F1> :cc<CR> |
|
:nnoremap <S-F1> :cc<CR> |
Vim's help is remarkably helpful, but in order to use it effectively you need to spend a few minutes learning how it is organised.
Getting started
Edit
Try these examples:
- Enter
:help to browse help. Scroll down the help page to see the quickref and tutor links, and the table of contents.
- Enter :help pattern for help on the topic pattern (for example).
:h pattern is the same (the :help command can be abbreviated).
Command completion can be used when entering a help topic:
- Type
:h patt then press Ctrl-D to list all topics that contain "patt".
- Type
:h patt then press Tab to scroll through the topics that start with "patt".
- If you have set the
'wildmenu' option (e.g. by using :set wildmenu), then :h patt followed by <Tab> opens a menu on the statusline, with all help topics containing "patt". You can select any item in the menu with the arrow keys or more presses of the <Tab> key to fill in the rest of your command line.
Links:
- Enter
:h to open the main help page.
- Type
/quick to search for "quick" (should find the quickref link).
- Press Ctrl-] to follow the link (jump to the quickref topic).
- After browsing the quickref topic, press Ctrl-T to go back to the previous topic.
- You can also press Ctrl-O to jump to older locations, or Ctrl-I to jump to newer locations.
Searching:
- Search within a help file using
/ like you would when searching any file.
- Search all the help files with the
:helpgrep command, for example:
:helpgrep \csearch.\{,12}file
\c means the pattern is case insensitive.
- The pattern finds "search" then up to 12 characters followed by "file".
- You will then see the first match. To see other matches for the same pattern, use:
:cnext
:cprev
:cnfile
:cpfile
:cfirst
:clast
- and even
:cc
- which brings you back to the current match after you scrolled the helpfile, or
:copen
- which will list out all the matches in a separate window. Read up on these commands with the
:help entry for each of them!
Each week (or more often if you prefer), read a new section from the :help page to learn something new!
Each help topic has a context:
| Prefix | Example | Context
|
: | :h :r | ex command (command starting with a colon)
|
| none | :h r | normal mode
|
v_ | :h v_r | visual mode
|
i_ | :h i_CTRL-W | insert mode
|
c_ | :h c_CTRL-R | ex command line
|
/ | :h /\r | search pattern (in this case, :h \r also works)
|
' | :h 'ro' | option
|
- | :h -r | Vim argument (starting Vim)
|
Sometimes you want to know what a particular control key means to Vim. For example, to see all help topics containing "ctrl-r", type :h ctrl-r then press Ctrl-D. The following examples show the help for pressing various keys in different contexts.
| Example | Help for key
|
:h CTRL-R | Ctrl-R in normal mode
|
:h i_CTRL-R | Ctrl-R in insert mode
|
:h c_CTRL-R | Ctrl-R in command mode
|
:h v_CTRL-V | Ctrl-V in visual mode
|
Simplify help navigation
Edit
The following mappings simplify navigation when viewing help:
- Press Enter to jump to the subject (topic) under the cursor.
- Press Backspace to return from the last jump.
- Press
s to find the next subject, or S to find the previous subject.
- Press
o to find the next option, or O to find the previous option.
Create file ~/.vim/ftplugin/help.vim (Unix) or $HOME/vimfiles/ftplugin/help.vim (Windows) containing:
nnoremap <buffer> <CR> <C-]>
nnoremap <buffer> <BS> <C-T>
nnoremap <buffer> o /'\l\{2,\}'<CR>
nnoremap <buffer> O ?'\l\{2,\}'<CR>
nnoremap <buffer> s /\|\zs\S\+\ze\|<CR>
nnoremap <buffer> S ?\|\zs\S\+\ze\|<CR>
The following mappings (which can go in your vimrc) simplify navigating the results of quickfix commands such as (among others) :helpgrep
:nnoremap <S-F1> :cc<CR>
:nnoremap <F2> :cnext<CR>
:nnoremap <S-F2> :cprev<CR>
:nnoremap <F3> :cnfile<CR>
:nnoremap <S-F3> :cpfile<CR>
:nnoremap <F4> :cfirst<CR>
:nnoremap <S-F4> :clast<CR>
References
Edit
Also see the wildmenu. My settings:
set wildmenu wildmode=longest:full,full
What it does:
- First tab: longest match, list in the statusbar.
- Following tabs: cycle through matches.