Shougo Matsushita | 5ddcecf | 2024-12-25 10:55:48 +0100 | [diff] [blame] | 1 | *helphelp.txt* For Vim version 9.1. Last change: 2024 Dec 25 |
Bram Moolenaar | 9160441 | 2010-06-03 20:25:18 +0200 | [diff] [blame] | 2 | |
| 3 | |
| 4 | VIM REFERENCE MANUAL by Bram Moolenaar |
| 5 | |
| 6 | |
| 7 | Help on help files *helphelp* |
| 8 | |
| 9 | 1. Help commands |online-help| |
Bram Moolenaar | 24ea3ba | 2010-09-19 19:01:21 +0200 | [diff] [blame] | 10 | 2. Translated help files |help-translated| |
Bram Moolenaar | 9160441 | 2010-06-03 20:25:18 +0200 | [diff] [blame] | 11 | 3. Writing help files |help-writing| |
| 12 | |
| 13 | ============================================================================== |
| 14 | 1. 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. |
Bram Moolenaar | 9160441 | 2010-06-03 20:25:18 +0200 | [diff] [blame] | 27 | |
| 28 | *{subject}* *E149* *E661* |
| 29 | :h[elp] {subject} Like ":help", additionally jump to the tag {subject}. |
Bram Moolenaar | 3df0173 | 2017-02-17 22:47:16 +0100 | [diff] [blame] | 30 | For example: > |
| 31 | :help options |
| 32 | |
| 33 | < {subject} can include wildcards such as "*", "?" and |
Bram Moolenaar | 9160441 | 2010-06-03 20:25:18 +0200 | [diff] [blame] | 34 | "[a-z]": |
| 35 | :help z? jump to help for any "z" command |
| 36 | :help z. jump to the help for "z." |
Bram Moolenaar | 3df0173 | 2017-02-17 22:47:16 +0100 | [diff] [blame] | 37 | But when a tag exists it is taken literally: |
| 38 | :help :? jump to help for ":?" |
| 39 | |
Bram Moolenaar | 9160441 | 2010-06-03 20:25:18 +0200 | [diff] [blame] | 40 | If there is no full match for the pattern, or there |
| 41 | are several matches, the "best" match will be used. |
| 42 | A sophisticated algorithm is used to decide which |
| 43 | match is better than another one. These items are |
| 44 | considered in the computation: |
| 45 | - A match with same case is much better than a match |
| 46 | with different case. |
| 47 | - A match that starts after a non-alphanumeric |
| 48 | character is better than a match in the middle of a |
| 49 | word. |
| 50 | - A match at or near the beginning of the tag is |
| 51 | better than a match further on. |
| 52 | - The more alphanumeric characters match, the better. |
| 53 | - The shorter the length of the match, the better. |
| 54 | |
| 55 | The 'helplang' option is used to select a language, if |
| 56 | the {subject} is available in several languages. |
| 57 | To find a tag in a specific language, append "@ab", |
| 58 | where "ab" is the two-letter language code. See |
| 59 | |help-translated|. |
| 60 | |
| 61 | Note that the longer the {subject} you give, the less |
| 62 | matches will be found. You can get an idea how this |
| 63 | all works by using commandline completion (type CTRL-D |
| 64 | after ":help subject" |c_CTRL-D|). |
| 65 | If there are several matches, you can have them listed |
| 66 | by hitting CTRL-D. Example: > |
| 67 | :help cont<Ctrl-D> |
Bram Moolenaar | 40af4e3 | 2010-07-29 22:33:18 +0200 | [diff] [blame] | 68 | |
| 69 | < Instead of typing ":help CTRL-V" to search for help |
| 70 | for CTRL-V you can type: > |
| 71 | :help ^V |
| 72 | < This also works together with other characters, for |
| 73 | example to find help for CTRL-V in Insert mode: > |
| 74 | :help i^V |
| 75 | < |
Bram Moolenaar | 3df0173 | 2017-02-17 22:47:16 +0100 | [diff] [blame] | 76 | It is also possible to first do ":help" and then |
Bram Moolenaar | 9160441 | 2010-06-03 20:25:18 +0200 | [diff] [blame] | 77 | use ":tag {pattern}" in the help window. The |
| 78 | ":tnext" command can then be used to jump to other |
| 79 | matches, "tselect" to list matches and choose one. > |
Bram Moolenaar | 3df0173 | 2017-02-17 22:47:16 +0100 | [diff] [blame] | 80 | :help index |
| 81 | :tselect /.*mode |
Bram Moolenaar | 40af4e3 | 2010-07-29 22:33:18 +0200 | [diff] [blame] | 82 | |
Bram Moolenaar | 9160441 | 2010-06-03 20:25:18 +0200 | [diff] [blame] | 83 | < When there is no argument you will see matches for |
| 84 | "help", to avoid listing all possible matches (that |
| 85 | would be very slow). |
| 86 | The number of matches displayed is limited to 300. |
| 87 | |
Bram Moolenaar | 3df0173 | 2017-02-17 22:47:16 +0100 | [diff] [blame] | 88 | The `:help` command can be followed by '|' and another |
Bram Moolenaar | 9160441 | 2010-06-03 20:25:18 +0200 | [diff] [blame] | 89 | command, but you don't need to escape the '|' inside a |
| 90 | help command. So these both work: > |
| 91 | :help | |
| 92 | :help k| only |
| 93 | < Note that a space before the '|' is seen as part of |
| 94 | the ":help" argument. |
Bram Moolenaar | 4072ba5 | 2020-12-23 13:56:35 +0100 | [diff] [blame] | 95 | You can also use <NL> or <CR> to separate the help |
Bram Moolenaar | 9160441 | 2010-06-03 20:25:18 +0200 | [diff] [blame] | 96 | command from a following command. You need to type |
Bram Moolenaar | 4072ba5 | 2020-12-23 13:56:35 +0100 | [diff] [blame] | 97 | CTRL-V first to insert the <NL> or <CR>. Example: > |
Bram Moolenaar | 9160441 | 2010-06-03 20:25:18 +0200 | [diff] [blame] | 98 | :help so<C-V><CR>only |
Bram Moolenaar | 9160441 | 2010-06-03 20:25:18 +0200 | [diff] [blame] | 99 | |
| 100 | :h[elp]! [subject] Like ":help", but in non-English help files prefer to |
| 101 | find a tag in a file with the same language as the |
| 102 | current file. See |help-translated|. |
| 103 | |
Bram Moolenaar | 938ae28 | 2023-02-20 20:44:55 +0000 | [diff] [blame] | 104 | *:helpc* *:helpclose* |
Bram Moolenaar | 96f45c0 | 2019-10-26 19:53:45 +0200 | [diff] [blame] | 105 | :helpc[lose] Close one help window, if there is one. |
| 106 | Vim will try to restore the window layout (including |
| 107 | cursor position) to the same layout it was before |
| 108 | opening the help window initially. This might cause |
| 109 | triggering several autocommands. |
Bram Moolenaar | 5bfa2ed | 2014-09-19 19:39:34 +0200 | [diff] [blame] | 110 | |
Bram Moolenaar | 9160441 | 2010-06-03 20:25:18 +0200 | [diff] [blame] | 111 | *:helpg* *:helpgrep* |
| 112 | :helpg[rep] {pattern}[@xx] |
| 113 | Search all help text files and make a list of lines |
| 114 | in which {pattern} matches. Jumps to the first match. |
| 115 | The optional [@xx] specifies that only matches in the |
| 116 | "xx" language are to be found. |
| 117 | You can navigate through the matches with the |
| 118 | |quickfix| commands, e.g., |:cnext| to jump to the |
| 119 | next one. Or use |:cwindow| to get the list of |
| 120 | matches in the quickfix window. |
| 121 | {pattern} is used as a Vim regexp |pattern|. |
| 122 | 'ignorecase' is not used, add "\c" to ignore case. |
| 123 | Example for case sensitive search: > |
| 124 | :helpgrep Uganda |
| 125 | < Example for case ignoring search: > |
| 126 | :helpgrep uganda\c |
| 127 | < Example for searching in French help: > |
| 128 | :helpgrep backspace@fr |
| 129 | < The pattern does not support line breaks, it must |
| 130 | match within one line. You can use |:grep| instead, |
| 131 | but then you need to get the list of help files in a |
| 132 | complicated way. |
| 133 | Cannot be followed by another command, everything is |
| 134 | used as part of the pattern. But you can use |
| 135 | |:execute| when needed. |
| 136 | Compressed help files will not be searched (Fedora |
| 137 | compresses the help files). |
Bram Moolenaar | 9160441 | 2010-06-03 20:25:18 +0200 | [diff] [blame] | 138 | |
| 139 | *:lh* *:lhelpgrep* |
| 140 | :lh[elpgrep] {pattern}[@xx] |
| 141 | Same as ":helpgrep", except the location list is used |
Bram Moolenaar | a8ffcbb | 2010-06-21 06:15:46 +0200 | [diff] [blame] | 142 | instead of the quickfix list. If the help window is |
Bram Moolenaar | 9160441 | 2010-06-03 20:25:18 +0200 | [diff] [blame] | 143 | already opened, then the location list for that window |
Bram Moolenaar | a8ffcbb | 2010-06-21 06:15:46 +0200 | [diff] [blame] | 144 | is used. Otherwise, a new help window is opened and |
Bram Moolenaar | 9160441 | 2010-06-03 20:25:18 +0200 | [diff] [blame] | 145 | the location list for that window is set. The |
Bram Moolenaar | 3c2881d | 2017-03-21 19:18:29 +0100 | [diff] [blame] | 146 | location list for the current window is not changed |
| 147 | then. |
Bram Moolenaar | 9160441 | 2010-06-03 20:25:18 +0200 | [diff] [blame] | 148 | |
| 149 | *:exu* *:exusage* |
| 150 | :exu[sage] Show help on Ex commands. Added to simulate the Nvi |
Bram Moolenaar | 25c9c68 | 2019-05-05 18:13:34 +0200 | [diff] [blame] | 151 | command. |
Bram Moolenaar | 9160441 | 2010-06-03 20:25:18 +0200 | [diff] [blame] | 152 | |
| 153 | *:viu* *:viusage* |
| 154 | :viu[sage] Show help on Normal mode commands. Added to simulate |
Bram Moolenaar | 25c9c68 | 2019-05-05 18:13:34 +0200 | [diff] [blame] | 155 | the Nvi command. |
Bram Moolenaar | 9160441 | 2010-06-03 20:25:18 +0200 | [diff] [blame] | 156 | |
| 157 | When no argument is given to |:help| the file given with the 'helpfile' option |
| 158 | will be opened. Otherwise the specified tag is searched for in all "doc/tags" |
| 159 | files in the directories specified in the 'runtimepath' option. |
| 160 | |
Bram Moolenaar | 7e6a515 | 2021-01-02 16:39:53 +0100 | [diff] [blame] | 161 | If you would like to open the help in the current window, see this tip: |
| 162 | |help-curwin|. |
| 163 | |
Bram Moolenaar | 9160441 | 2010-06-03 20:25:18 +0200 | [diff] [blame] | 164 | The initial height of the help window can be set with the 'helpheight' option |
| 165 | (default 20). |
Bram Moolenaar | 0e6adf8 | 2021-12-16 14:41:10 +0000 | [diff] [blame] | 166 | *help-buffer-options* |
Bram Moolenaar | 1b884a0 | 2020-12-10 21:11:27 +0100 | [diff] [blame] | 167 | When the help buffer is created, several local options are set to make sure |
| 168 | the help text is displayed as it was intended: |
| 169 | 'iskeyword' nearly all ASCII chars except ' ', '*', '"' and '|' |
| 170 | 'foldmethod' "manual" |
| 171 | 'tabstop' 8 |
| 172 | 'arabic' off |
| 173 | 'binary' off |
| 174 | 'buflisted' off |
| 175 | 'cursorbind' off |
| 176 | 'diff' off |
| 177 | 'foldenable' off |
| 178 | 'list' off |
| 179 | 'modifiable' off |
| 180 | 'number' off |
| 181 | 'relativenumber' off |
| 182 | 'rightleft' off |
| 183 | 'scrollbind' off |
| 184 | 'spell' off |
| 185 | |
Bram Moolenaar | 9160441 | 2010-06-03 20:25:18 +0200 | [diff] [blame] | 186 | Jump to specific subjects by using tags. This can be done in two ways: |
| 187 | - Use the "CTRL-]" command while standing on the name of a command or option. |
| 188 | This only works when the tag is a keyword. "<C-Leftmouse>" and |
| 189 | "g<LeftMouse>" work just like "CTRL-]". |
| 190 | - use the ":ta {subject}" command. This also works with non-keyword |
| 191 | characters. |
| 192 | |
| 193 | Use CTRL-T or CTRL-O to jump back. |
| 194 | Use ":q" to close the help window. |
| 195 | |
| 196 | If there are several matches for an item you are looking for, this is how you |
| 197 | can jump to each one of them: |
| 198 | 1. Open a help window |
| 199 | 2. Use the ":tag" command with a slash prepended to the tag. E.g.: > |
| 200 | :tag /min |
| 201 | 3. Use ":tnext" to jump to the next matching tag. |
| 202 | |
| 203 | It is possible to add help files for plugins and other items. You don't need |
| 204 | to change the distributed help files for that. See |add-local-help|. |
| 205 | |
| 206 | To write a local help file, see |write-local-help|. |
| 207 | |
| 208 | Note that the title lines from the local help files are automagically added to |
| 209 | the "LOCAL ADDITIONS" section in the "help.txt" help file |local-additions|. |
| 210 | This is done when viewing the file in Vim, the file itself is not changed. It |
| 211 | is done by going through all help files and obtaining the first line of each |
| 212 | file. The files in $VIMRUNTIME/doc are skipped. |
| 213 | |
| 214 | *help-xterm-window* |
| 215 | If you want to have the help in another xterm window, you could use this |
| 216 | command: > |
| 217 | :!xterm -e vim +help & |
| 218 | < |
| 219 | |
| 220 | *:helpfind* *:helpf* |
| 221 | :helpf[ind] Like |:help|, but use a dialog to enter the argument. |
| 222 | Only for backwards compatibility. It now executes the |
| 223 | ToolBar.FindHelp menu entry instead of using a builtin |
| 224 | dialog. {only when compiled with |+GUI_GTK|} |
Bram Moolenaar | 9160441 | 2010-06-03 20:25:18 +0200 | [diff] [blame] | 225 | |
| 226 | *:helpt* *:helptags* |
Bram Moolenaar | 2f0936c | 2022-01-08 21:51:59 +0000 | [diff] [blame] | 227 | *E150* *E151* *E152* *E153* *E154* *E670* |
Bram Moolenaar | 9160441 | 2010-06-03 20:25:18 +0200 | [diff] [blame] | 228 | :helpt[ags] [++t] {dir} |
| 229 | Generate the help tags file(s) for directory {dir}. |
Bram Moolenaar | e18c0b3 | 2016-03-20 21:08:34 +0100 | [diff] [blame] | 230 | When {dir} is ALL then all "doc" directories in |
| 231 | 'runtimepath' will be used. |
| 232 | |
Bram Moolenaar | 2df58b4 | 2012-11-28 18:21:11 +0100 | [diff] [blame] | 233 | All "*.txt" and "*.??x" files in the directory and |
| 234 | sub-directories are scanned for a help tag definition |
| 235 | in between stars. The "*.??x" files are for |
| 236 | translated docs, they generate the "tags-??" file, see |
| 237 | |help-translated|. The generated tags files are |
| 238 | sorted. |
Bram Moolenaar | 9160441 | 2010-06-03 20:25:18 +0200 | [diff] [blame] | 239 | When there are duplicates an error message is given. |
| 240 | An existing tags file is silently overwritten. |
Bram Moolenaar | 4f3f668 | 2016-03-26 23:01:59 +0100 | [diff] [blame] | 241 | |
Bram Moolenaar | 9160441 | 2010-06-03 20:25:18 +0200 | [diff] [blame] | 242 | The optional "++t" argument forces adding the |
| 243 | "help-tags" tag. This is also done when the {dir} is |
| 244 | equal to $VIMRUNTIME/doc. |
Bram Moolenaar | 4f3f668 | 2016-03-26 23:01:59 +0100 | [diff] [blame] | 245 | |
Bram Moolenaar | 9160441 | 2010-06-03 20:25:18 +0200 | [diff] [blame] | 246 | To rebuild the help tags in the runtime directory |
| 247 | (requires write permission there): > |
| 248 | :helptags $VIMRUNTIME/doc |
lagygoill | b3ec564 | 2024-11-02 17:58:01 +0100 | [diff] [blame] | 249 | < |
Christian Brabandt | cb34507 | 2024-11-19 23:02:57 +0100 | [diff] [blame] | 250 | *:HelpToc* *help-TOC* *help-toc-install* |
lagygoill | b3ec564 | 2024-11-02 17:58:01 +0100 | [diff] [blame] | 251 | |
| 252 | If you want to access an interactive table of contents, from any position in |
| 253 | the file, you can use the helptoc plugin. Load the plugin with: > |
| 254 | |
| 255 | packadd helptoc |
| 256 | |
| 257 | Then you can use the `:HelpToc` command to open a popup menu. |
| 258 | The latter supports the following normal commands: > |
| 259 | |
| 260 | key | effect |
| 261 | ----+--------------------------------------------------------- |
| 262 | j | select next entry |
| 263 | k | select previous entry |
| 264 | J | same as j, and jump to corresponding line in main buffer |
| 265 | K | same as k, and jump to corresponding line in main buffer |
| 266 | c | select nearest entry from cursor position in main buffer |
| 267 | g | select first entry |
| 268 | G | select last entry |
| 269 | H | collapse one level |
| 270 | L | expand one level |
| 271 | p | print current entry on command-line |
| 272 | |
| 273 | P | same as p but automatically, whenever selection changes |
| 274 | | press multiple times to toggle feature on/off |
| 275 | |
| 276 | q | quit menu |
| 277 | z | redraw menu with current entry at center |
| 278 | + | increase width of popup menu |
| 279 | - | decrease width of popup menu |
| 280 | ? | show/hide a help window |
Christian Brabandt | 6081c17 | 2024-11-03 09:06:10 +0100 | [diff] [blame] | 281 | / | search for pattern |
lagygoill | b3ec564 | 2024-11-02 17:58:01 +0100 | [diff] [blame] | 282 | |
| 283 | <C-D> | scroll down half a page |
| 284 | <C-U> | scroll up half a page |
| 285 | <PageUp> | scroll down a whole page |
| 286 | <PageDown> | scroll up a whole page |
| 287 | <Home> | select first entry |
| 288 | <End> | select last entry |
| 289 | |
| 290 | The plugin can also provide a table of contents in man pages, markdown files, |
| 291 | and terminal buffers. In the latter, the entries will be the past executed |
Christian Brabandt | 6081c17 | 2024-11-03 09:06:10 +0100 | [diff] [blame] | 292 | shell commands. To find those, the following pattern is used: > |
lagygoill | b3ec564 | 2024-11-02 17:58:01 +0100 | [diff] [blame] | 293 | |
| 294 | ^\w\+@\w\+:\f\+\$\s |
| 295 | |
| 296 | This is meant to match a default bash prompt. If it doesn't match your prompt, |
| 297 | you can change the regex with the `shell_prompt` key from the `g:helptoc` |
| 298 | dictionary variable: > |
| 299 | |
| 300 | let g:helptoc = {'shell_prompt': 'regex matching your shell prompt'} |
| 301 | |
| 302 | Tip: After inserting a pattern to look for with the `/` command, if you press |
| 303 | <Esc> instead of <CR>, you can then get more context for each remaining entry |
| 304 | by pressing `J` or `K`. |
Bram Moolenaar | 9160441 | 2010-06-03 20:25:18 +0200 | [diff] [blame] | 305 | |
| 306 | ============================================================================== |
| 307 | 2. Translated help files *help-translated* |
| 308 | |
| 309 | It is possible to add translated help files, next to the original English help |
| 310 | files. Vim will search for all help in "doc" directories in 'runtimepath'. |
| 311 | This is only available when compiled with the |+multi_lang| feature. |
| 312 | |
| 313 | At this moment translations are available for: |
Bram Moolenaar | 1aeaf8c | 2012-05-18 13:46:39 +0200 | [diff] [blame] | 314 | Chinese - multiple authors |
| 315 | French - translated by David Blanchet |
| 316 | Italian - translated by Antonio Colombo |
| 317 | Japanese - multiple authors |
| 318 | Polish - translated by Mikolaj Machowski |
| 319 | Russian - translated by Vassily Ragosin |
Bram Moolenaar | 9160441 | 2010-06-03 20:25:18 +0200 | [diff] [blame] | 320 | See the Vim website to find them: http://www.vim.org/translations.php |
| 321 | |
| 322 | A set of translated help files consists of these files: |
| 323 | |
| 324 | help.abx |
| 325 | howto.abx |
| 326 | ... |
| 327 | tags-ab |
| 328 | |
| 329 | "ab" is the two-letter language code. Thus for Italian the names are: |
| 330 | |
| 331 | help.itx |
| 332 | howto.itx |
| 333 | ... |
| 334 | tags-it |
| 335 | |
| 336 | The 'helplang' option can be set to the preferred language(s). The default is |
| 337 | set according to the environment. Vim will first try to find a matching tag |
| 338 | in the preferred language(s). English is used when it cannot be found. |
| 339 | |
| 340 | To find a tag in a specific language, append "@ab" to a tag, where "ab" is the |
| 341 | two-letter language code. Example: > |
| 342 | :he user-manual@it |
| 343 | :he user-manual@en |
| 344 | The first one finds the Italian user manual, even when 'helplang' is empty. |
| 345 | The second one finds the English user manual, even when 'helplang' is set to |
| 346 | "it". |
| 347 | |
| 348 | When using command-line completion for the ":help" command, the "@en" |
| 349 | extension is only shown when a tag exists for multiple languages. When the |
Bram Moolenaar | 7db8f6f | 2016-03-29 23:12:46 +0200 | [diff] [blame] | 350 | tag only exists for English "@en" is omitted. When the first candidate has an |
| 351 | "@ab" extension and it matches the first language in 'helplang' "@ab" is also |
| 352 | omitted. |
Bram Moolenaar | 9160441 | 2010-06-03 20:25:18 +0200 | [diff] [blame] | 353 | |
| 354 | When using |CTRL-]| or ":help!" in a non-English help file Vim will try to |
| 355 | find the tag in the same language. If not found then 'helplang' will be used |
| 356 | to select a language. |
| 357 | |
| 358 | Help files must use latin1 or utf-8 encoding. Vim assumes the encoding is |
| 359 | utf-8 when finding non-ASCII characters in the first line. Thus you must |
| 360 | translate the header with "For Vim version". |
| 361 | |
| 362 | The same encoding must be used for the help files of one language in one |
| 363 | directory. You can use a different encoding for different languages and use |
| 364 | a different encoding for help files of the same language but in a different |
| 365 | directory. |
| 366 | |
| 367 | Hints for translators: |
| 368 | - Do not translate the tags. This makes it possible to use 'helplang' to |
| 369 | specify the preferred language. You may add new tags in your language. |
| 370 | - When you do not translate a part of a file, add tags to the English version, |
| 371 | using the "tag@en" notation. |
| 372 | - Make a package with all the files and the tags file available for download. |
| 373 | Users can drop it in one of the "doc" directories and start use it. |
RestorerZ | c9ec20d | 2024-04-10 16:57:12 +0200 | [diff] [blame] | 374 | Report to the development team, so they can add a link on www.vim.org. |
Bram Moolenaar | 9160441 | 2010-06-03 20:25:18 +0200 | [diff] [blame] | 375 | - Use the |:helptags| command to generate the tags files. It will find all |
| 376 | languages in the specified directory. |
| 377 | |
| 378 | ============================================================================== |
| 379 | 3. Writing help files *help-writing* |
| 380 | |
Bram Moolenaar | 945e2db | 2010-06-05 17:43:32 +0200 | [diff] [blame] | 381 | For ease of use, a Vim help file for a plugin should follow the format of the |
Bram Moolenaar | 88a4205 | 2021-11-21 21:13:36 +0000 | [diff] [blame] | 382 | standard Vim help files, except for the first line. If you are writing a new |
Bram Moolenaar | 519cc55 | 2021-11-16 19:18:26 +0000 | [diff] [blame] | 383 | help file it's best to copy one of the existing files and use it as a |
| 384 | template. |
Bram Moolenaar | 945e2db | 2010-06-05 17:43:32 +0200 | [diff] [blame] | 385 | |
| 386 | The first line in a help file should have the following format: |
| 387 | |
Bram Moolenaar | 519cc55 | 2021-11-16 19:18:26 +0000 | [diff] [blame] | 388 | *plugin_name.txt* {short description of the plugin} |
Bram Moolenaar | 945e2db | 2010-06-05 17:43:32 +0200 | [diff] [blame] | 389 | |
Bram Moolenaar | 519cc55 | 2021-11-16 19:18:26 +0000 | [diff] [blame] | 390 | The first field is a help tag where ":help plugin_name" will jump to. The |
| 391 | remainder of the line, after a Tab, describes the plugin purpose in a short |
| 392 | way. This will show up in the "LOCAL ADDITIONS" section of the main help |
| 393 | file. Check there that it shows up properly: |local-additions|. |
| 394 | |
Bram Moolenaar | 88a4205 | 2021-11-21 21:13:36 +0000 | [diff] [blame] | 395 | If you want to add a version number or last modification date, put it in the |
Bram Moolenaar | 519cc55 | 2021-11-16 19:18:26 +0000 | [diff] [blame] | 396 | second line, right aligned. |
Bram Moolenaar | 945e2db | 2010-06-05 17:43:32 +0200 | [diff] [blame] | 397 | |
| 398 | At the bottom of the help file, place a Vim modeline to set the 'textwidth' |
Bram Moolenaar | 214641f | 2017-03-05 17:04:09 +0100 | [diff] [blame] | 399 | and 'tabstop' options and the 'filetype' to "help". Never set a global option |
Bram Moolenaar | 519cc55 | 2021-11-16 19:18:26 +0000 | [diff] [blame] | 400 | in such a modeline, that can have undesired consequences. |
Bram Moolenaar | 945e2db | 2010-06-05 17:43:32 +0200 | [diff] [blame] | 401 | |
| 402 | |
| 403 | TAGS |
| 404 | |
| 405 | To define a help tag, place the name between asterisks (*tag-name*). The |
| 406 | tag-name should be different from all the Vim help tag names and ideally |
Bram Moolenaar | a8ffcbb | 2010-06-21 06:15:46 +0200 | [diff] [blame] | 407 | should begin with the name of the Vim plugin. The tag name is usually right |
Bram Moolenaar | 945e2db | 2010-06-05 17:43:32 +0200 | [diff] [blame] | 408 | aligned on a line. |
| 409 | |
| 410 | When referring to an existing help tag and to create a hot-link, place the |
| 411 | name between two bars (|) eg. |help-writing|. |
| 412 | |
Bram Moolenaar | 03413f4 | 2016-04-12 21:07:15 +0200 | [diff] [blame] | 413 | When referring to a Vim command and to create a hot-link, place the |
| 414 | name between two backticks, eg. inside `:filetype`. You will see this is |
| 415 | highlighted as a command, like a code block (see below). |
| 416 | |
Bram Moolenaar | 945e2db | 2010-06-05 17:43:32 +0200 | [diff] [blame] | 417 | When referring to a Vim option in the help file, place the option name between |
Bram Moolenaar | a8ffcbb | 2010-06-21 06:15:46 +0200 | [diff] [blame] | 418 | two single quotes, eg. 'statusline' |
Bram Moolenaar | 945e2db | 2010-06-05 17:43:32 +0200 | [diff] [blame] | 419 | |
| 420 | |
| 421 | HIGHLIGHTING |
| 422 | |
Bram Moolenaar | a8ffcbb | 2010-06-21 06:15:46 +0200 | [diff] [blame] | 423 | To define a column heading, use a tilde character at the end of the line. |
| 424 | This will highlight the column heading in a different color. E.g. |
Bram Moolenaar | 945e2db | 2010-06-05 17:43:32 +0200 | [diff] [blame] | 425 | |
| 426 | Column heading~ |
| 427 | |
| 428 | To separate sections in a help file, place a series of '=' characters in a |
Bram Moolenaar | a8ffcbb | 2010-06-21 06:15:46 +0200 | [diff] [blame] | 429 | line starting from the first column. The section separator line is highlighted |
Bram Moolenaar | 945e2db | 2010-06-05 17:43:32 +0200 | [diff] [blame] | 430 | differently. |
| 431 | |
| 432 | To quote a block of ex-commands verbatim, place a greater than (>) character |
| 433 | at the end of the line before the block and a less than (<) character as the |
Bram Moolenaar | a8ffcbb | 2010-06-21 06:15:46 +0200 | [diff] [blame] | 434 | first non-blank on a line following the block. Any line starting in column 1 |
Bram Moolenaar | 945e2db | 2010-06-05 17:43:32 +0200 | [diff] [blame] | 435 | also implicitly stops the block of ex-commands before it. E.g. > |
Shougo Matsushita | 5ddcecf | 2024-12-25 10:55:48 +0100 | [diff] [blame] | 436 | function Example_Func() |
| 437 | echo "Example" |
| 438 | endfunction |
Bram Moolenaar | 945e2db | 2010-06-05 17:43:32 +0200 | [diff] [blame] | 439 | < |
Shougo Matsushita | 5ddcecf | 2024-12-25 10:55:48 +0100 | [diff] [blame] | 440 | |
| 441 | To add annotation in the block, place the annotation (ex: "lua") after a |
| 442 | greater than (>) character. E.g: >lua |
| 443 | print("hello") |
| 444 | < |
| 445 | Note: uses lua syntax highlighting, if "lua" key is in |
| 446 | |g:help_example_languages|. |
| 447 | |
| 448 | It's possible to add Vim syntax highlighting support to code examples. |
Shougo Matsushita | 6fea0a5 | 2024-12-15 20:47:37 +0100 | [diff] [blame] | 449 | E.g: >vim |
Shougo Matsushita | 5ddcecf | 2024-12-25 10:55:48 +0100 | [diff] [blame] | 450 | function Example_Func() |
| 451 | echo "Example" |
| 452 | endfunction |
Shougo Matsushita | 6fea0a5 | 2024-12-15 20:47:37 +0100 | [diff] [blame] | 453 | < |
Shougo Matsushita | 5ddcecf | 2024-12-25 10:55:48 +0100 | [diff] [blame] | 454 | *g:help_example_languages* |
| 455 | If you want to change the syntax highlighting in the block, you can |
| 456 | change it like this: > |
| 457 | :let g:help_example_languages = #{ vim: 'vim', sh: 'bash' } |
| 458 | The key represents the annotation marker name, and the value is the 'syntax' |
| 459 | name. By default, help files support only Vim script highlighting. |
| 460 | Note: When setting "g:help_example_languages", if you do not include "vim" |
| 461 | key, the Vim syntax highlighting will not be enabled. If you set it to an |
| 462 | empty value, syntax highlighting for embedded languages will be disabled. |
| 463 | |
Christian Brabandt | ae01b96 | 2024-12-25 17:52:12 +0100 | [diff] [blame] | 464 | Further note: including arbitrary syntax languages into help files may not |
Shougo Matsushita | 5ddcecf | 2024-12-25 10:55:48 +0100 | [diff] [blame] | 465 | always work perfectly, if the included 'syntax' script does not account for |
| 466 | such an import. |
| 467 | *help-notation* |
Bram Moolenaar | 945e2db | 2010-06-05 17:43:32 +0200 | [diff] [blame] | 468 | The following are highlighted differently in a Vim help file: |
| 469 | - a special key name expressed either in <> notation as in <PageDown>, or |
| 470 | as a Ctrl character as in CTRL-X |
| 471 | - anything between {braces}, e.g. {lhs} and {rhs} |
| 472 | |
| 473 | The word "Note", "Notes" and similar automagically receive distinctive |
| 474 | highlighting. So do these: |
| 475 | *Todo something to do |
| 476 | *Error something wrong |
| 477 | |
| 478 | You can find the details in $VIMRUNTIME/syntax/help.vim |
Bram Moolenaar | 9160441 | 2010-06-03 20:25:18 +0200 | [diff] [blame] | 479 | |
Ernie Rael | bee966d | 2023-11-11 09:09:47 +0100 | [diff] [blame] | 480 | |
| 481 | GENDER NEUTRAL LANGUAGE |
| 482 | |
| 483 | *gender-neutral* *inclusion* |
| 484 | Vim is for everybody, no matter race, gender or anything. For new or updated |
| 485 | help text, gender neutral language is recommended. Some of the help text is |
| 486 | many years old and there is no need to change it. We do not make any |
| 487 | assumptions about the gender of the user, no matter how the text is phrased. |
| 488 | The goal is that the reader understands how Vim works, the exact wording is |
Bram Moolenaar | e7b1ea0 | 2020-08-07 19:54:59 +0200 | [diff] [blame] | 489 | secondary. |
Bram Moolenaar | eab6dff | 2020-03-01 19:06:45 +0100 | [diff] [blame] | 490 | |
Ernie Rael | bee966d | 2023-11-11 09:09:47 +0100 | [diff] [blame] | 491 | Many online technical style guides include sections about gender neutral |
| 492 | language. Here are a few: > |
| 493 | |
| 494 | https://developers.google.com/style/pronouns |
| 495 | https://techwhirl.com/gender-neutral-technical-writing/ |
| 496 | https://www.skillsyouneed.com/write/gender-neutral-language.html |
| 497 | https://ualr.edu/writingcenter/avoid-sexist-language/ |
| 498 | < |
| 499 | Note: gender neutral language does not require using singular "they". |
Bram Moolenaar | eab6dff | 2020-03-01 19:06:45 +0100 | [diff] [blame] | 500 | |
Bram Moolenaar | 91f84f6 | 2018-07-29 15:07:52 +0200 | [diff] [blame] | 501 | vim:tw=78:ts=8:noet:ft=help:norl: |