blob: 8dcaa1f509591eb9cb07ec93d7c468ac6de69c1d [file] [log] [blame]
Bram Moolenaare7b1ea02020-08-07 19:54:59 +02001*helphelp.txt* For Vim version 8.2. Last change: 2020 Jul 27
Bram Moolenaar91604412010-06-03 20:25:18 +02002
3
4 VIM REFERENCE MANUAL by Bram Moolenaar
5
6
7Help on help files *helphelp*
8
91. Help commands |online-help|
Bram Moolenaar24ea3ba2010-09-19 19:01:21 +0200102. Translated help files |help-translated|
Bram Moolenaar91604412010-06-03 20:25:18 +0200113. Writing help files |help-writing|
12
13==============================================================================
141. Help commands *online-help*
15
16 *help* *<Help>* *:h* *:help* *<F1>* *i_<F1>* *i_<Help>*
17<Help> or
18:h[elp] Open a window and display the help file in read-only
19 mode. If there is a help window open already, use
20 that one. Otherwise, if the current window uses the
21 full width of the screen or is at least 80 characters
22 wide, the help window will appear just above the
23 current window. Otherwise the new window is put at
24 the very top.
25 The 'helplang' option is used to select a language, if
26 the main help file is available in several languages.
Bram Moolenaar91604412010-06-03 20:25:18 +020027
28 *{subject}* *E149* *E661*
29:h[elp] {subject} Like ":help", additionally jump to the tag {subject}.
Bram Moolenaar3df01732017-02-17 22:47:16 +010030 For example: >
31 :help options
32
33< {subject} can include wildcards such as "*", "?" and
Bram Moolenaar91604412010-06-03 20:25:18 +020034 "[a-z]":
35 :help z? jump to help for any "z" command
36 :help z. jump to the help for "z."
Bram Moolenaar3df01732017-02-17 22:47:16 +010037 But when a tag exists it is taken literally:
38 :help :? jump to help for ":?"
39
Bram Moolenaar91604412010-06-03 20:25:18 +020040 If there is no full match for the pattern, or there
41 are several matches, the "best" match will be used.
42 A sophisticated algorithm is used to decide which
43 match is better than another one. These items are
44 considered in the computation:
45 - A match with same case is much better than a match
46 with different case.
47 - A match that starts after a non-alphanumeric
48 character is better than a match in the middle of a
49 word.
50 - A match at or near the beginning of the tag is
51 better than a match further on.
52 - The more alphanumeric characters match, the better.
53 - The shorter the length of the match, the better.
54
55 The 'helplang' option is used to select a language, if
56 the {subject} is available in several languages.
57 To find a tag in a specific language, append "@ab",
58 where "ab" is the two-letter language code. See
59 |help-translated|.
60
61 Note that the longer the {subject} you give, the less
62 matches will be found. You can get an idea how this
63 all works by using commandline completion (type CTRL-D
64 after ":help subject" |c_CTRL-D|).
65 If there are several matches, you can have them listed
66 by hitting CTRL-D. Example: >
67 :help cont<Ctrl-D>
Bram Moolenaar40af4e32010-07-29 22:33:18 +020068
69< Instead of typing ":help CTRL-V" to search for help
70 for CTRL-V you can type: >
71 :help ^V
72< This also works together with other characters, for
73 example to find help for CTRL-V in Insert mode: >
74 :help i^V
75<
Bram Moolenaar3df01732017-02-17 22:47:16 +010076 It is also possible to first do ":help" and then
Bram Moolenaar91604412010-06-03 20:25:18 +020077 use ":tag {pattern}" in the help window. The
78 ":tnext" command can then be used to jump to other
79 matches, "tselect" to list matches and choose one. >
Bram Moolenaar3df01732017-02-17 22:47:16 +010080 :help index
81 :tselect /.*mode
Bram Moolenaar40af4e32010-07-29 22:33:18 +020082
Bram Moolenaar91604412010-06-03 20:25:18 +020083< When there is no argument you will see matches for
84 "help", to avoid listing all possible matches (that
85 would be very slow).
86 The number of matches displayed is limited to 300.
87
Bram Moolenaar3df01732017-02-17 22:47:16 +010088 The `:help` command can be followed by '|' and another
Bram Moolenaar91604412010-06-03 20:25:18 +020089 command, but you don't need to escape the '|' inside a
90 help command. So these both work: >
91 :help |
92 :help k| only
93< Note that a space before the '|' is seen as part of
94 the ":help" argument.
95 You can also use <LF> or <CR> to separate the help
96 command from a following command. You need to type
97 CTRL-V first to insert the <LF> or <CR>. Example: >
98 :help so<C-V><CR>only
Bram Moolenaar91604412010-06-03 20:25:18 +020099
100:h[elp]! [subject] Like ":help", but in non-English help files prefer to
101 find a tag in a file with the same language as the
102 current file. See |help-translated|.
103
Bram Moolenaar5bfa2ed2014-09-19 19:39:34 +0200104 *:helpc* *:helpclose*
Bram Moolenaar96f45c02019-10-26 19:53:45 +0200105:helpc[lose] Close one help window, if there is one.
106 Vim will try to restore the window layout (including
107 cursor position) to the same layout it was before
108 opening the help window initially. This might cause
109 triggering several autocommands.
Bram Moolenaar5bfa2ed2014-09-19 19:39:34 +0200110
Bram Moolenaar91604412010-06-03 20:25:18 +0200111 *:helpg* *:helpgrep*
112:helpg[rep] {pattern}[@xx]
113 Search all help text files and make a list of lines
114 in which {pattern} matches. Jumps to the first match.
115 The optional [@xx] specifies that only matches in the
116 "xx" language are to be found.
117 You can navigate through the matches with the
118 |quickfix| commands, e.g., |:cnext| to jump to the
119 next one. Or use |:cwindow| to get the list of
120 matches in the quickfix window.
121 {pattern} is used as a Vim regexp |pattern|.
122 'ignorecase' is not used, add "\c" to ignore case.
123 Example for case sensitive search: >
124 :helpgrep Uganda
125< Example for case ignoring search: >
126 :helpgrep uganda\c
127< Example for searching in French help: >
128 :helpgrep backspace@fr
129< The pattern does not support line breaks, it must
130 match within one line. You can use |:grep| instead,
131 but then you need to get the list of help files in a
132 complicated way.
133 Cannot be followed by another command, everything is
134 used as part of the pattern. But you can use
135 |:execute| when needed.
136 Compressed help files will not be searched (Fedora
137 compresses the help files).
Bram Moolenaar91604412010-06-03 20:25:18 +0200138
139 *:lh* *:lhelpgrep*
140:lh[elpgrep] {pattern}[@xx]
141 Same as ":helpgrep", except the location list is used
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +0200142 instead of the quickfix list. If the help window is
Bram Moolenaar91604412010-06-03 20:25:18 +0200143 already opened, then the location list for that window
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +0200144 is used. Otherwise, a new help window is opened and
Bram Moolenaar91604412010-06-03 20:25:18 +0200145 the location list for that window is set. The
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100146 location list for the current window is not changed
147 then.
Bram Moolenaar91604412010-06-03 20:25:18 +0200148
149 *:exu* *:exusage*
150:exu[sage] Show help on Ex commands. Added to simulate the Nvi
Bram Moolenaar25c9c682019-05-05 18:13:34 +0200151 command.
Bram Moolenaar91604412010-06-03 20:25:18 +0200152
153 *:viu* *:viusage*
154:viu[sage] Show help on Normal mode commands. Added to simulate
Bram Moolenaar25c9c682019-05-05 18:13:34 +0200155 the Nvi command.
Bram Moolenaar91604412010-06-03 20:25:18 +0200156
157When no argument is given to |:help| the file given with the 'helpfile' option
158will be opened. Otherwise the specified tag is searched for in all "doc/tags"
159files in the directories specified in the 'runtimepath' option.
160
161The initial height of the help window can be set with the 'helpheight' option
162(default 20).
163
164Jump to specific subjects by using tags. This can be done in two ways:
165- Use the "CTRL-]" command while standing on the name of a command or option.
166 This only works when the tag is a keyword. "<C-Leftmouse>" and
167 "g<LeftMouse>" work just like "CTRL-]".
168- use the ":ta {subject}" command. This also works with non-keyword
169 characters.
170
171Use CTRL-T or CTRL-O to jump back.
172Use ":q" to close the help window.
173
174If there are several matches for an item you are looking for, this is how you
175can jump to each one of them:
1761. Open a help window
1772. Use the ":tag" command with a slash prepended to the tag. E.g.: >
178 :tag /min
1793. Use ":tnext" to jump to the next matching tag.
180
181It is possible to add help files for plugins and other items. You don't need
182to change the distributed help files for that. See |add-local-help|.
183
184To write a local help file, see |write-local-help|.
185
186Note that the title lines from the local help files are automagically added to
187the "LOCAL ADDITIONS" section in the "help.txt" help file |local-additions|.
188This is done when viewing the file in Vim, the file itself is not changed. It
189is done by going through all help files and obtaining the first line of each
190file. The files in $VIMRUNTIME/doc are skipped.
191
192 *help-xterm-window*
193If you want to have the help in another xterm window, you could use this
194command: >
195 :!xterm -e vim +help &
196<
197
198 *:helpfind* *:helpf*
199:helpf[ind] Like |:help|, but use a dialog to enter the argument.
200 Only for backwards compatibility. It now executes the
201 ToolBar.FindHelp menu entry instead of using a builtin
202 dialog. {only when compiled with |+GUI_GTK|}
Bram Moolenaar91604412010-06-03 20:25:18 +0200203
204 *:helpt* *:helptags*
205 *E154* *E150* *E151* *E152* *E153* *E670*
206:helpt[ags] [++t] {dir}
207 Generate the help tags file(s) for directory {dir}.
Bram Moolenaare18c0b32016-03-20 21:08:34 +0100208 When {dir} is ALL then all "doc" directories in
209 'runtimepath' will be used.
210
Bram Moolenaar2df58b42012-11-28 18:21:11 +0100211 All "*.txt" and "*.??x" files in the directory and
212 sub-directories are scanned for a help tag definition
213 in between stars. The "*.??x" files are for
214 translated docs, they generate the "tags-??" file, see
215 |help-translated|. The generated tags files are
216 sorted.
Bram Moolenaar91604412010-06-03 20:25:18 +0200217 When there are duplicates an error message is given.
218 An existing tags file is silently overwritten.
Bram Moolenaar4f3f6682016-03-26 23:01:59 +0100219
Bram Moolenaar91604412010-06-03 20:25:18 +0200220 The optional "++t" argument forces adding the
221 "help-tags" tag. This is also done when the {dir} is
222 equal to $VIMRUNTIME/doc.
Bram Moolenaar4f3f6682016-03-26 23:01:59 +0100223
Bram Moolenaar91604412010-06-03 20:25:18 +0200224 To rebuild the help tags in the runtime directory
225 (requires write permission there): >
226 :helptags $VIMRUNTIME/doc
Bram Moolenaar91604412010-06-03 20:25:18 +0200227
228==============================================================================
2292. Translated help files *help-translated*
230
231It is possible to add translated help files, next to the original English help
232files. Vim will search for all help in "doc" directories in 'runtimepath'.
233This is only available when compiled with the |+multi_lang| feature.
234
235At this moment translations are available for:
Bram Moolenaar1aeaf8c2012-05-18 13:46:39 +0200236 Chinese - multiple authors
237 French - translated by David Blanchet
238 Italian - translated by Antonio Colombo
239 Japanese - multiple authors
240 Polish - translated by Mikolaj Machowski
241 Russian - translated by Vassily Ragosin
Bram Moolenaar91604412010-06-03 20:25:18 +0200242See the Vim website to find them: http://www.vim.org/translations.php
243
244A set of translated help files consists of these files:
245
246 help.abx
247 howto.abx
248 ...
249 tags-ab
250
251"ab" is the two-letter language code. Thus for Italian the names are:
252
253 help.itx
254 howto.itx
255 ...
256 tags-it
257
258The 'helplang' option can be set to the preferred language(s). The default is
259set according to the environment. Vim will first try to find a matching tag
260in the preferred language(s). English is used when it cannot be found.
261
262To find a tag in a specific language, append "@ab" to a tag, where "ab" is the
263two-letter language code. Example: >
264 :he user-manual@it
265 :he user-manual@en
266The first one finds the Italian user manual, even when 'helplang' is empty.
267The second one finds the English user manual, even when 'helplang' is set to
268"it".
269
270When using command-line completion for the ":help" command, the "@en"
271extension is only shown when a tag exists for multiple languages. When the
Bram Moolenaar7db8f6f2016-03-29 23:12:46 +0200272tag only exists for English "@en" is omitted. When the first candidate has an
273"@ab" extension and it matches the first language in 'helplang' "@ab" is also
274omitted.
Bram Moolenaar91604412010-06-03 20:25:18 +0200275
276When using |CTRL-]| or ":help!" in a non-English help file Vim will try to
277find the tag in the same language. If not found then 'helplang' will be used
278to select a language.
279
280Help files must use latin1 or utf-8 encoding. Vim assumes the encoding is
281utf-8 when finding non-ASCII characters in the first line. Thus you must
282translate the header with "For Vim version".
283
284The same encoding must be used for the help files of one language in one
285directory. You can use a different encoding for different languages and use
286a different encoding for help files of the same language but in a different
287directory.
288
289Hints for translators:
290- Do not translate the tags. This makes it possible to use 'helplang' to
291 specify the preferred language. You may add new tags in your language.
292- When you do not translate a part of a file, add tags to the English version,
293 using the "tag@en" notation.
294- Make a package with all the files and the tags file available for download.
295 Users can drop it in one of the "doc" directories and start use it.
296 Report this to Bram, so that he can add a link on www.vim.org.
297- Use the |:helptags| command to generate the tags files. It will find all
298 languages in the specified directory.
299
300==============================================================================
3013. Writing help files *help-writing*
302
Bram Moolenaar945e2db2010-06-05 17:43:32 +0200303For ease of use, a Vim help file for a plugin should follow the format of the
304standard Vim help files. If you are writing a new help file it's best to copy
305one of the existing files and use it as a template.
306
307The first line in a help file should have the following format:
308
309*helpfile_name.txt* For Vim version 7.3 Last change: 2010 June 4
310
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +0200311The first field is a link to the help file name. The second field describes
312the applicable Vim version. The last field specifies the last modification
313date of the file. Each field is separated by a tab.
Bram Moolenaar945e2db2010-06-05 17:43:32 +0200314
315At the bottom of the help file, place a Vim modeline to set the 'textwidth'
Bram Moolenaar214641f2017-03-05 17:04:09 +0100316and 'tabstop' options and the 'filetype' to "help". Never set a global option
Bram Moolenaar945e2db2010-06-05 17:43:32 +0200317in such a modeline, that can have consequences undesired by whoever reads that
318help.
319
320
321TAGS
322
323To define a help tag, place the name between asterisks (*tag-name*). The
324tag-name should be different from all the Vim help tag names and ideally
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +0200325should begin with the name of the Vim plugin. The tag name is usually right
Bram Moolenaar945e2db2010-06-05 17:43:32 +0200326aligned on a line.
327
328When referring to an existing help tag and to create a hot-link, place the
329name between two bars (|) eg. |help-writing|.
330
Bram Moolenaar03413f42016-04-12 21:07:15 +0200331When referring to a Vim command and to create a hot-link, place the
332name between two backticks, eg. inside `:filetype`. You will see this is
333highlighted as a command, like a code block (see below).
334
Bram Moolenaar945e2db2010-06-05 17:43:32 +0200335When referring to a Vim option in the help file, place the option name between
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +0200336two single quotes, eg. 'statusline'
Bram Moolenaar945e2db2010-06-05 17:43:32 +0200337
338
339HIGHLIGHTING
340
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +0200341To define a column heading, use a tilde character at the end of the line.
342This will highlight the column heading in a different color. E.g.
Bram Moolenaar945e2db2010-06-05 17:43:32 +0200343
344Column heading~
345
346To separate sections in a help file, place a series of '=' characters in a
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +0200347line starting from the first column. The section separator line is highlighted
Bram Moolenaar945e2db2010-06-05 17:43:32 +0200348differently.
349
350To quote a block of ex-commands verbatim, place a greater than (>) character
351at the end of the line before the block and a less than (<) character as the
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +0200352first non-blank on a line following the block. Any line starting in column 1
Bram Moolenaar945e2db2010-06-05 17:43:32 +0200353also implicitly stops the block of ex-commands before it. E.g. >
354 function Example_Func()
355 echo "Example"
356 endfunction
357<
358
359The following are highlighted differently in a Vim help file:
360 - a special key name expressed either in <> notation as in <PageDown>, or
361 as a Ctrl character as in CTRL-X
362 - anything between {braces}, e.g. {lhs} and {rhs}
363
364The word "Note", "Notes" and similar automagically receive distinctive
365highlighting. So do these:
366 *Todo something to do
367 *Error something wrong
368
369You can find the details in $VIMRUNTIME/syntax/help.vim
Bram Moolenaar91604412010-06-03 20:25:18 +0200370
Bram Moolenaareab6dff2020-03-01 19:06:45 +0100371 *inclusion*
Bram Moolenaare7b1ea02020-08-07 19:54:59 +0200372Vim is for everybody, no matter race, gender or anything. Some people make a
373big deal about using "he" or "his" when referring to the user, thinking it
374means we assume the user is male. That is not the case, it's just a habit of
375writing help text, which quite often is many years old. Also, a lot of the
376text is written by contributors for whom English is not their first language.
377We do not make any assumptions about the gender of the user, no matter how the
378text is phrased. Some people have suggested using "they", but that is not
379regular English. We do not want to spend much time on this discussion. The
380goal is that the reader understands how Vim works, the exact wording is
381secondary.
Bram Moolenaareab6dff2020-03-01 19:06:45 +0100382
383
Bram Moolenaar91f84f62018-07-29 15:07:52 +0200384 vim:tw=78:ts=8:noet:ft=help:norl: