helphelp.txt 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. *helphelp.txt* For Vim version 9.0. Last change: 2022 Jan 08
  2. VIM REFERENCE MANUAL by Bram Moolenaar
  3. Help on help files *helphelp*
  4. 1. Help commands |online-help|
  5. 2. Translated help files |help-translated|
  6. 3. Writing help files |help-writing|
  7. ==============================================================================
  8. 1. Help commands *online-help*
  9. *help* *<Help>* *:h* *:help* *<F1>* *i_<F1>* *i_<Help>*
  10. <Help> or
  11. :h[elp] Open a window and display the help file in read-only
  12. mode. If there is a help window open already, use
  13. that one. Otherwise, if the current window uses the
  14. full width of the screen or is at least 80 characters
  15. wide, the help window will appear just above the
  16. current window. Otherwise the new window is put at
  17. the very top.
  18. The 'helplang' option is used to select a language, if
  19. the main help file is available in several languages.
  20. *{subject}* *E149* *E661*
  21. :h[elp] {subject} Like ":help", additionally jump to the tag {subject}.
  22. For example: >
  23. :help options
  24. < {subject} can include wildcards such as "*", "?" and
  25. "[a-z]":
  26. :help z? jump to help for any "z" command
  27. :help z. jump to the help for "z."
  28. But when a tag exists it is taken literally:
  29. :help :? jump to help for ":?"
  30. If there is no full match for the pattern, or there
  31. are several matches, the "best" match will be used.
  32. A sophisticated algorithm is used to decide which
  33. match is better than another one. These items are
  34. considered in the computation:
  35. - A match with same case is much better than a match
  36. with different case.
  37. - A match that starts after a non-alphanumeric
  38. character is better than a match in the middle of a
  39. word.
  40. - A match at or near the beginning of the tag is
  41. better than a match further on.
  42. - The more alphanumeric characters match, the better.
  43. - The shorter the length of the match, the better.
  44. The 'helplang' option is used to select a language, if
  45. the {subject} is available in several languages.
  46. To find a tag in a specific language, append "@ab",
  47. where "ab" is the two-letter language code. See
  48. |help-translated|.
  49. Note that the longer the {subject} you give, the less
  50. matches will be found. You can get an idea how this
  51. all works by using commandline completion (type CTRL-D
  52. after ":help subject" |c_CTRL-D|).
  53. If there are several matches, you can have them listed
  54. by hitting CTRL-D. Example: >
  55. :help cont<Ctrl-D>
  56. < Instead of typing ":help CTRL-V" to search for help
  57. for CTRL-V you can type: >
  58. :help ^V
  59. < This also works together with other characters, for
  60. example to find help for CTRL-V in Insert mode: >
  61. :help i^V
  62. <
  63. It is also possible to first do ":help" and then
  64. use ":tag {pattern}" in the help window. The
  65. ":tnext" command can then be used to jump to other
  66. matches, "tselect" to list matches and choose one. >
  67. :help index
  68. :tselect /.*mode
  69. < When there is no argument you will see matches for
  70. "help", to avoid listing all possible matches (that
  71. would be very slow).
  72. The number of matches displayed is limited to 300.
  73. The `:help` command can be followed by '|' and another
  74. command, but you don't need to escape the '|' inside a
  75. help command. So these both work: >
  76. :help |
  77. :help k| only
  78. < Note that a space before the '|' is seen as part of
  79. the ":help" argument.
  80. You can also use <NL> or <CR> to separate the help
  81. command from a following command. You need to type
  82. CTRL-V first to insert the <NL> or <CR>. Example: >
  83. :help so<C-V><CR>only
  84. :h[elp]! [subject] Like ":help", but in non-English help files prefer to
  85. find a tag in a file with the same language as the
  86. current file. See |help-translated|.
  87. *:helpc* *:helpclose*
  88. :helpc[lose] Close one help window, if there is one.
  89. Vim will try to restore the window layout (including
  90. cursor position) to the same layout it was before
  91. opening the help window initially. This might cause
  92. triggering several autocommands.
  93. *:helpg* *:helpgrep*
  94. :helpg[rep] {pattern}[@xx]
  95. Search all help text files and make a list of lines
  96. in which {pattern} matches. Jumps to the first match.
  97. The optional [@xx] specifies that only matches in the
  98. "xx" language are to be found.
  99. You can navigate through the matches with the
  100. |quickfix| commands, e.g., |:cnext| to jump to the
  101. next one. Or use |:cwindow| to get the list of
  102. matches in the quickfix window.
  103. {pattern} is used as a Vim regexp |pattern|.
  104. 'ignorecase' is not used, add "\c" to ignore case.
  105. Example for case sensitive search: >
  106. :helpgrep Uganda
  107. < Example for case ignoring search: >
  108. :helpgrep uganda\c
  109. < Example for searching in French help: >
  110. :helpgrep backspace@fr
  111. < The pattern does not support line breaks, it must
  112. match within one line. You can use |:grep| instead,
  113. but then you need to get the list of help files in a
  114. complicated way.
  115. Cannot be followed by another command, everything is
  116. used as part of the pattern. But you can use
  117. |:execute| when needed.
  118. Compressed help files will not be searched (Fedora
  119. compresses the help files).
  120. *:lh* *:lhelpgrep*
  121. :lh[elpgrep] {pattern}[@xx]
  122. Same as ":helpgrep", except the location list is used
  123. instead of the quickfix list. If the help window is
  124. already opened, then the location list for that window
  125. is used. Otherwise, a new help window is opened and
  126. the location list for that window is set. The
  127. location list for the current window is not changed
  128. then.
  129. *:exu* *:exusage*
  130. :exu[sage] Show help on Ex commands. Added to simulate the Nvi
  131. command.
  132. *:viu* *:viusage*
  133. :viu[sage] Show help on Normal mode commands. Added to simulate
  134. the Nvi command.
  135. When no argument is given to |:help| the file given with the 'helpfile' option
  136. will be opened. Otherwise the specified tag is searched for in all "doc/tags"
  137. files in the directories specified in the 'runtimepath' option.
  138. If you would like to open the help in the current window, see this tip:
  139. |help-curwin|.
  140. The initial height of the help window can be set with the 'helpheight' option
  141. (default 20).
  142. *help-buffer-options*
  143. When the help buffer is created, several local options are set to make sure
  144. the help text is displayed as it was intended:
  145. 'iskeyword' nearly all ASCII chars except ' ', '*', '"' and '|'
  146. 'foldmethod' "manual"
  147. 'tabstop' 8
  148. 'arabic' off
  149. 'binary' off
  150. 'buflisted' off
  151. 'cursorbind' off
  152. 'diff' off
  153. 'foldenable' off
  154. 'list' off
  155. 'modifiable' off
  156. 'number' off
  157. 'relativenumber' off
  158. 'rightleft' off
  159. 'scrollbind' off
  160. 'spell' off
  161. Jump to specific subjects by using tags. This can be done in two ways:
  162. - Use the "CTRL-]" command while standing on the name of a command or option.
  163. This only works when the tag is a keyword. "<C-Leftmouse>" and
  164. "g<LeftMouse>" work just like "CTRL-]".
  165. - use the ":ta {subject}" command. This also works with non-keyword
  166. characters.
  167. Use CTRL-T or CTRL-O to jump back.
  168. Use ":q" to close the help window.
  169. If there are several matches for an item you are looking for, this is how you
  170. can jump to each one of them:
  171. 1. Open a help window
  172. 2. Use the ":tag" command with a slash prepended to the tag. E.g.: >
  173. :tag /min
  174. 3. Use ":tnext" to jump to the next matching tag.
  175. It is possible to add help files for plugins and other items. You don't need
  176. to change the distributed help files for that. See |add-local-help|.
  177. To write a local help file, see |write-local-help|.
  178. Note that the title lines from the local help files are automagically added to
  179. the "LOCAL ADDITIONS" section in the "help.txt" help file |local-additions|.
  180. This is done when viewing the file in Vim, the file itself is not changed. It
  181. is done by going through all help files and obtaining the first line of each
  182. file. The files in $VIMRUNTIME/doc are skipped.
  183. *help-xterm-window*
  184. If you want to have the help in another xterm window, you could use this
  185. command: >
  186. :!xterm -e vim +help &
  187. <
  188. *:helpfind* *:helpf*
  189. :helpf[ind] Like |:help|, but use a dialog to enter the argument.
  190. Only for backwards compatibility. It now executes the
  191. ToolBar.FindHelp menu entry instead of using a builtin
  192. dialog. {only when compiled with |+GUI_GTK|}
  193. *:helpt* *:helptags*
  194. *E150* *E151* *E152* *E153* *E154* *E670*
  195. :helpt[ags] [++t] {dir}
  196. Generate the help tags file(s) for directory {dir}.
  197. When {dir} is ALL then all "doc" directories in
  198. 'runtimepath' will be used.
  199. All "*.txt" and "*.??x" files in the directory and
  200. sub-directories are scanned for a help tag definition
  201. in between stars. The "*.??x" files are for
  202. translated docs, they generate the "tags-??" file, see
  203. |help-translated|. The generated tags files are
  204. sorted.
  205. When there are duplicates an error message is given.
  206. An existing tags file is silently overwritten.
  207. The optional "++t" argument forces adding the
  208. "help-tags" tag. This is also done when the {dir} is
  209. equal to $VIMRUNTIME/doc.
  210. To rebuild the help tags in the runtime directory
  211. (requires write permission there): >
  212. :helptags $VIMRUNTIME/doc
  213. ==============================================================================
  214. 2. Translated help files *help-translated*
  215. It is possible to add translated help files, next to the original English help
  216. files. Vim will search for all help in "doc" directories in 'runtimepath'.
  217. This is only available when compiled with the |+multi_lang| feature.
  218. At this moment translations are available for:
  219. Chinese - multiple authors
  220. French - translated by David Blanchet
  221. Italian - translated by Antonio Colombo
  222. Japanese - multiple authors
  223. Polish - translated by Mikolaj Machowski
  224. Russian - translated by Vassily Ragosin
  225. See the Vim website to find them: http://www.vim.org/translations.php
  226. A set of translated help files consists of these files:
  227. help.abx
  228. howto.abx
  229. ...
  230. tags-ab
  231. "ab" is the two-letter language code. Thus for Italian the names are:
  232. help.itx
  233. howto.itx
  234. ...
  235. tags-it
  236. The 'helplang' option can be set to the preferred language(s). The default is
  237. set according to the environment. Vim will first try to find a matching tag
  238. in the preferred language(s). English is used when it cannot be found.
  239. To find a tag in a specific language, append "@ab" to a tag, where "ab" is the
  240. two-letter language code. Example: >
  241. :he user-manual@it
  242. :he user-manual@en
  243. The first one finds the Italian user manual, even when 'helplang' is empty.
  244. The second one finds the English user manual, even when 'helplang' is set to
  245. "it".
  246. When using command-line completion for the ":help" command, the "@en"
  247. extension is only shown when a tag exists for multiple languages. When the
  248. tag only exists for English "@en" is omitted. When the first candidate has an
  249. "@ab" extension and it matches the first language in 'helplang' "@ab" is also
  250. omitted.
  251. When using |CTRL-]| or ":help!" in a non-English help file Vim will try to
  252. find the tag in the same language. If not found then 'helplang' will be used
  253. to select a language.
  254. Help files must use latin1 or utf-8 encoding. Vim assumes the encoding is
  255. utf-8 when finding non-ASCII characters in the first line. Thus you must
  256. translate the header with "For Vim version".
  257. The same encoding must be used for the help files of one language in one
  258. directory. You can use a different encoding for different languages and use
  259. a different encoding for help files of the same language but in a different
  260. directory.
  261. Hints for translators:
  262. - Do not translate the tags. This makes it possible to use 'helplang' to
  263. specify the preferred language. You may add new tags in your language.
  264. - When you do not translate a part of a file, add tags to the English version,
  265. using the "tag@en" notation.
  266. - Make a package with all the files and the tags file available for download.
  267. Users can drop it in one of the "doc" directories and start use it.
  268. Report this to Bram, so that he can add a link on www.vim.org.
  269. - Use the |:helptags| command to generate the tags files. It will find all
  270. languages in the specified directory.
  271. ==============================================================================
  272. 3. Writing help files *help-writing*
  273. For ease of use, a Vim help file for a plugin should follow the format of the
  274. standard Vim help files, except for the first line. If you are writing a new
  275. help file it's best to copy one of the existing files and use it as a
  276. template.
  277. The first line in a help file should have the following format:
  278. *plugin_name.txt* {short description of the plugin}
  279. The first field is a help tag where ":help plugin_name" will jump to. The
  280. remainder of the line, after a Tab, describes the plugin purpose in a short
  281. way. This will show up in the "LOCAL ADDITIONS" section of the main help
  282. file. Check there that it shows up properly: |local-additions|.
  283. If you want to add a version number or last modification date, put it in the
  284. second line, right aligned.
  285. At the bottom of the help file, place a Vim modeline to set the 'textwidth'
  286. and 'tabstop' options and the 'filetype' to "help". Never set a global option
  287. in such a modeline, that can have undesired consequences.
  288. TAGS
  289. To define a help tag, place the name between asterisks (*tag-name*). The
  290. tag-name should be different from all the Vim help tag names and ideally
  291. should begin with the name of the Vim plugin. The tag name is usually right
  292. aligned on a line.
  293. When referring to an existing help tag and to create a hot-link, place the
  294. name between two bars (|) eg. |help-writing|.
  295. When referring to a Vim command and to create a hot-link, place the
  296. name between two backticks, eg. inside `:filetype`. You will see this is
  297. highlighted as a command, like a code block (see below).
  298. When referring to a Vim option in the help file, place the option name between
  299. two single quotes, eg. 'statusline'
  300. HIGHLIGHTING
  301. To define a column heading, use a tilde character at the end of the line.
  302. This will highlight the column heading in a different color. E.g.
  303. Column heading~
  304. To separate sections in a help file, place a series of '=' characters in a
  305. line starting from the first column. The section separator line is highlighted
  306. differently.
  307. To quote a block of ex-commands verbatim, place a greater than (>) character
  308. at the end of the line before the block and a less than (<) character as the
  309. first non-blank on a line following the block. Any line starting in column 1
  310. also implicitly stops the block of ex-commands before it. E.g. >
  311. function Example_Func()
  312. echo "Example"
  313. endfunction
  314. <
  315. The following are highlighted differently in a Vim help file:
  316. - a special key name expressed either in <> notation as in <PageDown>, or
  317. as a Ctrl character as in CTRL-X
  318. - anything between {braces}, e.g. {lhs} and {rhs}
  319. The word "Note", "Notes" and similar automagically receive distinctive
  320. highlighting. So do these:
  321. *Todo something to do
  322. *Error something wrong
  323. You can find the details in $VIMRUNTIME/syntax/help.vim
  324. *inclusion*
  325. Vim is for everybody, no matter race, gender or anything. Some people make a
  326. big deal about using "he" or "his" when referring to the user, thinking it
  327. means we assume the user is male. That is not the case, it's just a habit of
  328. writing help text, which quite often is many years old. Also, a lot of the
  329. text is written by contributors for whom English is not their first language.
  330. We do not make any assumptions about the gender of the user, no matter how the
  331. text is phrased. Some people have suggested using "they", but that is not
  332. regular English. We do not want to spend much time on this discussion. The
  333. goal is that the reader understands how Vim works, the exact wording is
  334. secondary.
  335. vim:tw=78:ts=8:noet:ft=help:norl: