blob: 32051d49639be3392517e34b97524c98c2a58cdd [file] [log] [blame]
Bram Moolenaar3df01732017-02-17 22:47:16 +01001*helphelp.txt* For Vim version 8.0. Last change: 2017 Feb 09
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.
27 {not in Vi}
28
29 *{subject}* *E149* *E661*
30:h[elp] {subject} Like ":help", additionally jump to the tag {subject}.
Bram Moolenaar3df01732017-02-17 22:47:16 +010031 For example: >
32 :help options
33
34< {subject} can include wildcards such as "*", "?" and
Bram Moolenaar91604412010-06-03 20:25:18 +020035 "[a-z]":
36 :help z? jump to help for any "z" command
37 :help z. jump to the help for "z."
Bram Moolenaar3df01732017-02-17 22:47:16 +010038 But when a tag exists it is taken literally:
39 :help :? jump to help for ":?"
40
Bram Moolenaar91604412010-06-03 20:25:18 +020041 If there is no full match for the pattern, or there
42 are several matches, the "best" match will be used.
43 A sophisticated algorithm is used to decide which
44 match is better than another one. These items are
45 considered in the computation:
46 - A match with same case is much better than a match
47 with different case.
48 - A match that starts after a non-alphanumeric
49 character is better than a match in the middle of a
50 word.
51 - A match at or near the beginning of the tag is
52 better than a match further on.
53 - The more alphanumeric characters match, the better.
54 - The shorter the length of the match, the better.
55
56 The 'helplang' option is used to select a language, if
57 the {subject} is available in several languages.
58 To find a tag in a specific language, append "@ab",
59 where "ab" is the two-letter language code. See
60 |help-translated|.
61
62 Note that the longer the {subject} you give, the less
63 matches will be found. You can get an idea how this
64 all works by using commandline completion (type CTRL-D
65 after ":help subject" |c_CTRL-D|).
66 If there are several matches, you can have them listed
67 by hitting CTRL-D. Example: >
68 :help cont<Ctrl-D>
Bram Moolenaar40af4e32010-07-29 22:33:18 +020069
70< Instead of typing ":help CTRL-V" to search for help
71 for CTRL-V you can type: >
72 :help ^V
73< This also works together with other characters, for
74 example to find help for CTRL-V in Insert mode: >
75 :help i^V
76<
Bram Moolenaar3df01732017-02-17 22:47:16 +010077 It is also possible to first do ":help" and then
Bram Moolenaar91604412010-06-03 20:25:18 +020078 use ":tag {pattern}" in the help window. The
79 ":tnext" command can then be used to jump to other
80 matches, "tselect" to list matches and choose one. >
Bram Moolenaar3df01732017-02-17 22:47:16 +010081 :help index
82 :tselect /.*mode
Bram Moolenaar40af4e32010-07-29 22:33:18 +020083
Bram Moolenaar91604412010-06-03 20:25:18 +020084< When there is no argument you will see matches for
85 "help", to avoid listing all possible matches (that
86 would be very slow).
87 The number of matches displayed is limited to 300.
88
Bram Moolenaar3df01732017-02-17 22:47:16 +010089 The `:help` command can be followed by '|' and another
Bram Moolenaar91604412010-06-03 20:25:18 +020090 command, but you don't need to escape the '|' inside a
91 help command. So these both work: >
92 :help |
93 :help k| only
94< Note that a space before the '|' is seen as part of
95 the ":help" argument.
96 You can also use <LF> or <CR> to separate the help
97 command from a following command. You need to type
98 CTRL-V first to insert the <LF> or <CR>. Example: >
99 :help so<C-V><CR>only
100< {not in Vi}
101
102:h[elp]! [subject] Like ":help", but in non-English help files prefer to
103 find a tag in a file with the same language as the
104 current file. See |help-translated|.
105
Bram Moolenaar5bfa2ed2014-09-19 19:39:34 +0200106 *:helpc* *:helpclose*
Bram Moolenaar91e15e12014-09-19 22:38:48 +0200107:helpc[lose] Close one help window, if there is one.
Bram Moolenaar5bfa2ed2014-09-19 19:39:34 +0200108
Bram Moolenaar91604412010-06-03 20:25:18 +0200109 *:helpg* *:helpgrep*
110:helpg[rep] {pattern}[@xx]
111 Search all help text files and make a list of lines
112 in which {pattern} matches. Jumps to the first match.
113 The optional [@xx] specifies that only matches in the
114 "xx" language are to be found.
115 You can navigate through the matches with the
116 |quickfix| commands, e.g., |:cnext| to jump to the
117 next one. Or use |:cwindow| to get the list of
118 matches in the quickfix window.
119 {pattern} is used as a Vim regexp |pattern|.
120 'ignorecase' is not used, add "\c" to ignore case.
121 Example for case sensitive search: >
122 :helpgrep Uganda
123< Example for case ignoring search: >
124 :helpgrep uganda\c
125< Example for searching in French help: >
126 :helpgrep backspace@fr
127< The pattern does not support line breaks, it must
128 match within one line. You can use |:grep| instead,
129 but then you need to get the list of help files in a
130 complicated way.
131 Cannot be followed by another command, everything is
132 used as part of the pattern. But you can use
133 |:execute| when needed.
134 Compressed help files will not be searched (Fedora
135 compresses the help files).
136 {not in Vi}
137
138 *:lh* *:lhelpgrep*
139:lh[elpgrep] {pattern}[@xx]
140 Same as ":helpgrep", except the location list is used
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +0200141 instead of the quickfix list. If the help window is
Bram Moolenaar91604412010-06-03 20:25:18 +0200142 already opened, then the location list for that window
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +0200143 is used. Otherwise, a new help window is opened and
Bram Moolenaar91604412010-06-03 20:25:18 +0200144 the location list for that window is set. The
145 location list for the current window is not changed.
146
147 *:exu* *:exusage*
148:exu[sage] Show help on Ex commands. Added to simulate the Nvi
149 command. {not in Vi}
150
151 *:viu* *:viusage*
152:viu[sage] Show help on Normal mode commands. Added to simulate
153 the Nvi command. {not in Vi}
154
155When no argument is given to |:help| the file given with the 'helpfile' option
156will be opened. Otherwise the specified tag is searched for in all "doc/tags"
157files in the directories specified in the 'runtimepath' option.
158
159The initial height of the help window can be set with the 'helpheight' option
160(default 20).
161
162Jump to specific subjects by using tags. This can be done in two ways:
163- Use the "CTRL-]" command while standing on the name of a command or option.
164 This only works when the tag is a keyword. "<C-Leftmouse>" and
165 "g<LeftMouse>" work just like "CTRL-]".
166- use the ":ta {subject}" command. This also works with non-keyword
167 characters.
168
169Use CTRL-T or CTRL-O to jump back.
170Use ":q" to close the help window.
171
172If there are several matches for an item you are looking for, this is how you
173can jump to each one of them:
1741. Open a help window
1752. Use the ":tag" command with a slash prepended to the tag. E.g.: >
176 :tag /min
1773. Use ":tnext" to jump to the next matching tag.
178
179It is possible to add help files for plugins and other items. You don't need
180to change the distributed help files for that. See |add-local-help|.
181
182To write a local help file, see |write-local-help|.
183
184Note that the title lines from the local help files are automagically added to
185the "LOCAL ADDITIONS" section in the "help.txt" help file |local-additions|.
186This is done when viewing the file in Vim, the file itself is not changed. It
187is done by going through all help files and obtaining the first line of each
188file. The files in $VIMRUNTIME/doc are skipped.
189
190 *help-xterm-window*
191If you want to have the help in another xterm window, you could use this
192command: >
193 :!xterm -e vim +help &
194<
195
196 *:helpfind* *:helpf*
197:helpf[ind] Like |:help|, but use a dialog to enter the argument.
198 Only for backwards compatibility. It now executes the
199 ToolBar.FindHelp menu entry instead of using a builtin
200 dialog. {only when compiled with |+GUI_GTK|}
Bram Moolenaar24ea3ba2010-09-19 19:01:21 +0200201 {not in Vi}
Bram Moolenaar91604412010-06-03 20:25:18 +0200202
203 *:helpt* *:helptags*
204 *E154* *E150* *E151* *E152* *E153* *E670*
205:helpt[ags] [++t] {dir}
206 Generate the help tags file(s) for directory {dir}.
Bram Moolenaare18c0b32016-03-20 21:08:34 +0100207 When {dir} is ALL then all "doc" directories in
208 'runtimepath' will be used.
209
Bram Moolenaar2df58b42012-11-28 18:21:11 +0100210 All "*.txt" and "*.??x" files in the directory and
211 sub-directories are scanned for a help tag definition
212 in between stars. The "*.??x" files are for
213 translated docs, they generate the "tags-??" file, see
214 |help-translated|. The generated tags files are
215 sorted.
Bram Moolenaar91604412010-06-03 20:25:18 +0200216 When there are duplicates an error message is given.
217 An existing tags file is silently overwritten.
Bram Moolenaar4f3f6682016-03-26 23:01:59 +0100218
Bram Moolenaar91604412010-06-03 20:25:18 +0200219 The optional "++t" argument forces adding the
220 "help-tags" tag. This is also done when the {dir} is
221 equal to $VIMRUNTIME/doc.
Bram Moolenaar4f3f6682016-03-26 23:01:59 +0100222
Bram Moolenaar91604412010-06-03 20:25:18 +0200223 To rebuild the help tags in the runtime directory
224 (requires write permission there): >
225 :helptags $VIMRUNTIME/doc
226< {not in Vi}
227
228
229==============================================================================
2302. Translated help files *help-translated*
231
232It is possible to add translated help files, next to the original English help
233files. Vim will search for all help in "doc" directories in 'runtimepath'.
234This is only available when compiled with the |+multi_lang| feature.
235
236At this moment translations are available for:
Bram Moolenaar1aeaf8c2012-05-18 13:46:39 +0200237 Chinese - multiple authors
238 French - translated by David Blanchet
239 Italian - translated by Antonio Colombo
240 Japanese - multiple authors
241 Polish - translated by Mikolaj Machowski
242 Russian - translated by Vassily Ragosin
Bram Moolenaar91604412010-06-03 20:25:18 +0200243See the Vim website to find them: http://www.vim.org/translations.php
244
245A set of translated help files consists of these files:
246
247 help.abx
248 howto.abx
249 ...
250 tags-ab
251
252"ab" is the two-letter language code. Thus for Italian the names are:
253
254 help.itx
255 howto.itx
256 ...
257 tags-it
258
259The 'helplang' option can be set to the preferred language(s). The default is
260set according to the environment. Vim will first try to find a matching tag
261in the preferred language(s). English is used when it cannot be found.
262
263To find a tag in a specific language, append "@ab" to a tag, where "ab" is the
264two-letter language code. Example: >
265 :he user-manual@it
266 :he user-manual@en
267The first one finds the Italian user manual, even when 'helplang' is empty.
268The second one finds the English user manual, even when 'helplang' is set to
269"it".
270
271When using command-line completion for the ":help" command, the "@en"
272extension is only shown when a tag exists for multiple languages. When the
Bram Moolenaar7db8f6f2016-03-29 23:12:46 +0200273tag only exists for English "@en" is omitted. When the first candidate has an
274"@ab" extension and it matches the first language in 'helplang' "@ab" is also
275omitted.
Bram Moolenaar91604412010-06-03 20:25:18 +0200276
277When using |CTRL-]| or ":help!" in a non-English help file Vim will try to
278find the tag in the same language. If not found then 'helplang' will be used
279to select a language.
280
281Help files must use latin1 or utf-8 encoding. Vim assumes the encoding is
282utf-8 when finding non-ASCII characters in the first line. Thus you must
283translate the header with "For Vim version".
284
285The same encoding must be used for the help files of one language in one
286directory. You can use a different encoding for different languages and use
287a different encoding for help files of the same language but in a different
288directory.
289
290Hints for translators:
291- Do not translate the tags. This makes it possible to use 'helplang' to
292 specify the preferred language. You may add new tags in your language.
293- When you do not translate a part of a file, add tags to the English version,
294 using the "tag@en" notation.
295- Make a package with all the files and the tags file available for download.
296 Users can drop it in one of the "doc" directories and start use it.
297 Report this to Bram, so that he can add a link on www.vim.org.
298- Use the |:helptags| command to generate the tags files. It will find all
299 languages in the specified directory.
300
301==============================================================================
3023. Writing help files *help-writing*
303
Bram Moolenaar945e2db2010-06-05 17:43:32 +0200304For ease of use, a Vim help file for a plugin should follow the format of the
305standard Vim help files. If you are writing a new help file it's best to copy
306one of the existing files and use it as a template.
307
308The first line in a help file should have the following format:
309
310*helpfile_name.txt* For Vim version 7.3 Last change: 2010 June 4
311
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +0200312The first field is a link to the help file name. The second field describes
313the applicable Vim version. The last field specifies the last modification
314date of the file. Each field is separated by a tab.
Bram Moolenaar945e2db2010-06-05 17:43:32 +0200315
316At the bottom of the help file, place a Vim modeline to set the 'textwidth'
317and 'tabstop' options and the 'filetype' to 'help'. Never set a global option
318in such a modeline, that can have consequences undesired by whoever reads that
319help.
320
321
322TAGS
323
324To define a help tag, place the name between asterisks (*tag-name*). The
325tag-name should be different from all the Vim help tag names and ideally
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +0200326should begin with the name of the Vim plugin. The tag name is usually right
Bram Moolenaar945e2db2010-06-05 17:43:32 +0200327aligned on a line.
328
329When referring to an existing help tag and to create a hot-link, place the
330name between two bars (|) eg. |help-writing|.
331
Bram Moolenaar03413f42016-04-12 21:07:15 +0200332When referring to a Vim command and to create a hot-link, place the
333name between two backticks, eg. inside `:filetype`. You will see this is
334highlighted as a command, like a code block (see below).
335
Bram Moolenaar945e2db2010-06-05 17:43:32 +0200336When referring to a Vim option in the help file, place the option name between
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +0200337two single quotes, eg. 'statusline'
Bram Moolenaar945e2db2010-06-05 17:43:32 +0200338
339
340HIGHLIGHTING
341
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +0200342To define a column heading, use a tilde character at the end of the line.
343This will highlight the column heading in a different color. E.g.
Bram Moolenaar945e2db2010-06-05 17:43:32 +0200344
345Column heading~
346
347To separate sections in a help file, place a series of '=' characters in a
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +0200348line starting from the first column. The section separator line is highlighted
Bram Moolenaar945e2db2010-06-05 17:43:32 +0200349differently.
350
351To quote a block of ex-commands verbatim, place a greater than (>) character
352at the end of the line before the block and a less than (<) character as the
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +0200353first non-blank on a line following the block. Any line starting in column 1
Bram Moolenaar945e2db2010-06-05 17:43:32 +0200354also implicitly stops the block of ex-commands before it. E.g. >
355 function Example_Func()
356 echo "Example"
357 endfunction
358<
359
360The following are highlighted differently in a Vim help file:
361 - a special key name expressed either in <> notation as in <PageDown>, or
362 as a Ctrl character as in CTRL-X
363 - anything between {braces}, e.g. {lhs} and {rhs}
364
365The word "Note", "Notes" and similar automagically receive distinctive
366highlighting. So do these:
367 *Todo something to do
368 *Error something wrong
369
370You can find the details in $VIMRUNTIME/syntax/help.vim
Bram Moolenaar91604412010-06-03 20:25:18 +0200371
372 vim:tw=78:ts=8:ft=help:norl: