xref: /vim-8.2.3635/runtime/doc/helphelp.txt (revision 94688b8a)
1*helphelp.txt*	For Vim version 8.1.  Last change: 2017 Mar 19
2
3
4		  VIM REFERENCE MANUAL    by Bram Moolenaar
5
6
7Help on help files					*helphelp*
8
91. Help commands		|online-help|
102. Translated help files	|help-translated|
113. 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			For example:  >
32				:help options
33
34<			{subject} can include wildcards such as "*", "?" and
35			"[a-z]":
36			   :help z?	jump to help for any "z" command
37			   :help z.	jump to the help for "z."
38			But when a tag exists it is taken literally:
39			   :help :?	jump to help for ":?"
40
41			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>
69
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<
77			It is also possible to first do ":help" and then
78			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. >
81				:help index
82				:tselect /.*mode
83
84<			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
89			The `:help` command can be followed by '|' and another
90			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
106						 	*:helpc* *:helpclose*
107:helpc[lose]            Close one help window, if there is one.
108
109							*: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
141			instead of the quickfix list.  If the help window is
142			already opened, then the location list for that window
143			is used.  Otherwise, a new help window is opened and
144			the location list for that window is set.  The
145			location list for the current window is not changed
146			then.
147
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|}
202			{not in Vi}
203
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}.
208			When {dir} is ALL then all "doc" directories in
209			'runtimepath' will be used.
210
211			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.
217			When there are duplicates an error message is given.
218			An existing tags file is silently overwritten.
219
220			The optional "++t" argument forces adding the
221			"help-tags" tag.  This is also done when the {dir} is
222			equal to $VIMRUNTIME/doc.
223
224			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:
238	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
244See 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
274tag 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.
277
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
305For 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
313The 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.
316
317At the bottom of the help file, place a Vim modeline to set the 'textwidth'
318and 'tabstop' options and the 'filetype' to "help".  Never set a global option
319in 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
327should begin with the name of the Vim plugin.  The tag name is usually right
328aligned 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
333When 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
337When referring to a Vim option in the help file, place the option name between
338two single quotes, eg. 'statusline'
339
340
341HIGHLIGHTING
342
343To 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.
345
346Column heading~
347
348To separate sections in a help file, place a series of '=' characters in a
349line starting from the first column.  The section separator line is highlighted
350differently.
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
354first non-blank on a line following the block.  Any line starting in column 1
355also 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
372
373 vim:tw=78:ts=8:noet:ft=help:norl:
374