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