blob: 29941c1aeb1be8368e944d2ff78ac1a3f155f131 [file] [log] [blame]
Bram Moolenaarb1c91982018-05-17 17:04:55 +02001*helphelp.txt* For Vim version 8.1. Last change: 2017 Mar 19
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
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100145 location list for the current window is not changed
146 then.
Bram Moolenaar91604412010-06-03 20:25:18 +0200147
148 *:exu* *:exusage*
149:exu[sage] Show help on Ex commands. Added to simulate the Nvi
150 command. {not in Vi}
151
152 *:viu* *:viusage*
153:viu[sage] Show help on Normal mode commands. Added to simulate
154 the Nvi command. {not in Vi}
155
156When no argument is given to |:help| the file given with the 'helpfile' option
157will be opened. Otherwise the specified tag is searched for in all "doc/tags"
158files in the directories specified in the 'runtimepath' option.
159
160The initial height of the help window can be set with the 'helpheight' option
161(default 20).
162
163Jump to specific subjects by using tags. This can be done in two ways:
164- Use the "CTRL-]" command while standing on the name of a command or option.
165 This only works when the tag is a keyword. "<C-Leftmouse>" and
166 "g<LeftMouse>" work just like "CTRL-]".
167- use the ":ta {subject}" command. This also works with non-keyword
168 characters.
169
170Use CTRL-T or CTRL-O to jump back.
171Use ":q" to close the help window.
172
173If there are several matches for an item you are looking for, this is how you
174can jump to each one of them:
1751. Open a help window
1762. Use the ":tag" command with a slash prepended to the tag. E.g.: >
177 :tag /min
1783. Use ":tnext" to jump to the next matching tag.
179
180It is possible to add help files for plugins and other items. You don't need
181to change the distributed help files for that. See |add-local-help|.
182
183To write a local help file, see |write-local-help|.
184
185Note that the title lines from the local help files are automagically added to
186the "LOCAL ADDITIONS" section in the "help.txt" help file |local-additions|.
187This is done when viewing the file in Vim, the file itself is not changed. It
188is done by going through all help files and obtaining the first line of each
189file. The files in $VIMRUNTIME/doc are skipped.
190
191 *help-xterm-window*
192If you want to have the help in another xterm window, you could use this
193command: >
194 :!xterm -e vim +help &
195<
196
197 *:helpfind* *:helpf*
198:helpf[ind] Like |:help|, but use a dialog to enter the argument.
199 Only for backwards compatibility. It now executes the
200 ToolBar.FindHelp menu entry instead of using a builtin
201 dialog. {only when compiled with |+GUI_GTK|}
Bram Moolenaar24ea3ba2010-09-19 19:01:21 +0200202 {not in Vi}
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
227< {not in Vi}
228
229
230==============================================================================
2312. Translated help files *help-translated*
232
233It is possible to add translated help files, next to the original English help
234files. Vim will search for all help in "doc" directories in 'runtimepath'.
235This is only available when compiled with the |+multi_lang| feature.
236
237At this moment translations are available for:
Bram Moolenaar1aeaf8c2012-05-18 13:46:39 +0200238 Chinese - multiple authors
239 French - translated by David Blanchet
240 Italian - translated by Antonio Colombo
241 Japanese - multiple authors
242 Polish - translated by Mikolaj Machowski
243 Russian - translated by Vassily Ragosin
Bram Moolenaar91604412010-06-03 20:25:18 +0200244See the Vim website to find them: http://www.vim.org/translations.php
245
246A set of translated help files consists of these files:
247
248 help.abx
249 howto.abx
250 ...
251 tags-ab
252
253"ab" is the two-letter language code. Thus for Italian the names are:
254
255 help.itx
256 howto.itx
257 ...
258 tags-it
259
260The 'helplang' option can be set to the preferred language(s). The default is
261set according to the environment. Vim will first try to find a matching tag
262in the preferred language(s). English is used when it cannot be found.
263
264To find a tag in a specific language, append "@ab" to a tag, where "ab" is the
265two-letter language code. Example: >
266 :he user-manual@it
267 :he user-manual@en
268The first one finds the Italian user manual, even when 'helplang' is empty.
269The second one finds the English user manual, even when 'helplang' is set to
270"it".
271
272When using command-line completion for the ":help" command, the "@en"
273extension is only shown when a tag exists for multiple languages. When the
Bram Moolenaar7db8f6f2016-03-29 23:12:46 +0200274tag only exists for English "@en" is omitted. When the first candidate has an
275"@ab" extension and it matches the first language in 'helplang' "@ab" is also
276omitted.
Bram Moolenaar91604412010-06-03 20:25:18 +0200277
278When using |CTRL-]| or ":help!" in a non-English help file Vim will try to
279find the tag in the same language. If not found then 'helplang' will be used
280to select a language.
281
282Help files must use latin1 or utf-8 encoding. Vim assumes the encoding is
283utf-8 when finding non-ASCII characters in the first line. Thus you must
284translate the header with "For Vim version".
285
286The same encoding must be used for the help files of one language in one
287directory. You can use a different encoding for different languages and use
288a different encoding for help files of the same language but in a different
289directory.
290
291Hints for translators:
292- Do not translate the tags. This makes it possible to use 'helplang' to
293 specify the preferred language. You may add new tags in your language.
294- When you do not translate a part of a file, add tags to the English version,
295 using the "tag@en" notation.
296- Make a package with all the files and the tags file available for download.
297 Users can drop it in one of the "doc" directories and start use it.
298 Report this to Bram, so that he can add a link on www.vim.org.
299- Use the |:helptags| command to generate the tags files. It will find all
300 languages in the specified directory.
301
302==============================================================================
3033. Writing help files *help-writing*
304
Bram Moolenaar945e2db2010-06-05 17:43:32 +0200305For ease of use, a Vim help file for a plugin should follow the format of the
306standard Vim help files. If you are writing a new help file it's best to copy
307one of the existing files and use it as a template.
308
309The first line in a help file should have the following format:
310
311*helpfile_name.txt* For Vim version 7.3 Last change: 2010 June 4
312
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +0200313The first field is a link to the help file name. The second field describes
314the applicable Vim version. The last field specifies the last modification
315date of the file. Each field is separated by a tab.
Bram Moolenaar945e2db2010-06-05 17:43:32 +0200316
317At the bottom of the help file, place a Vim modeline to set the 'textwidth'
Bram Moolenaar214641f2017-03-05 17:04:09 +0100318and 'tabstop' options and the 'filetype' to "help". Never set a global option
Bram Moolenaar945e2db2010-06-05 17:43:32 +0200319in such a modeline, that can have consequences undesired by whoever reads that
320help.
321
322
323TAGS
324
325To define a help tag, place the name between asterisks (*tag-name*). The
326tag-name should be different from all the Vim help tag names and ideally
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +0200327should begin with the name of the Vim plugin. The tag name is usually right
Bram Moolenaar945e2db2010-06-05 17:43:32 +0200328aligned on a line.
329
330When referring to an existing help tag and to create a hot-link, place the
331name between two bars (|) eg. |help-writing|.
332
Bram Moolenaar03413f42016-04-12 21:07:15 +0200333When referring to a Vim command and to create a hot-link, place the
334name between two backticks, eg. inside `:filetype`. You will see this is
335highlighted as a command, like a code block (see below).
336
Bram Moolenaar945e2db2010-06-05 17:43:32 +0200337When referring to a Vim option in the help file, place the option name between
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +0200338two single quotes, eg. 'statusline'
Bram Moolenaar945e2db2010-06-05 17:43:32 +0200339
340
341HIGHLIGHTING
342
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +0200343To define a column heading, use a tilde character at the end of the line.
344This will highlight the column heading in a different color. E.g.
Bram Moolenaar945e2db2010-06-05 17:43:32 +0200345
346Column heading~
347
348To separate sections in a help file, place a series of '=' characters in a
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +0200349line starting from the first column. The section separator line is highlighted
Bram Moolenaar945e2db2010-06-05 17:43:32 +0200350differently.
351
352To quote a block of ex-commands verbatim, place a greater than (>) character
353at the end of the line before the block and a less than (<) character as the
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +0200354first non-blank on a line following the block. Any line starting in column 1
Bram Moolenaar945e2db2010-06-05 17:43:32 +0200355also implicitly stops the block of ex-commands before it. E.g. >
356 function Example_Func()
357 echo "Example"
358 endfunction
359<
360
361The following are highlighted differently in a Vim help file:
362 - a special key name expressed either in <> notation as in <PageDown>, or
363 as a Ctrl character as in CTRL-X
364 - anything between {braces}, e.g. {lhs} and {rhs}
365
366The word "Note", "Notes" and similar automagically receive distinctive
367highlighting. So do these:
368 *Todo something to do
369 *Error something wrong
370
371You can find the details in $VIMRUNTIME/syntax/help.vim
Bram Moolenaar91604412010-06-03 20:25:18 +0200372
373 vim:tw=78:ts=8:ft=help:norl: