]> git.madduck.net Git - etc/vim.git/blob - doc/vim-markdown.txt

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Update doc
[etc/vim.git] / doc / vim-markdown.txt
1 *vim-markdown*  Vim Markdown
2
3 ===============================================================================
4 Contents ~
5
6  1. Introduction                                    |vim-markdown-introduction|
7  2. Installation                                    |vim-markdown-installation|
8  3. Options                                              |vim-markdown-options|
9   1. Disable Folding                             |vim-markdown-disable-folding|
10   2. Change fold style                         |vim-markdown-change-fold-style|
11   3. Set header folding level           |vim-markdown-set-header-folding-level|
12   4. Disable Default Key Mappings   |vim-markdown-disable-default-key-mappings|
13   5. Enable TOC window auto-fit       |vim-markdown-enable-toc-window-auto-fit|
14   6. Text emphasis restriction to single-lines
15                        |vim-markdown-text-emphasis-restriction-to-single-lines|
16   7. Syntax Concealing                         |vim-markdown-syntax-concealing|
17   8. Fenced code block languages     |vim-markdown-fenced-code-block-languages|
18   9. Follow named anchors                   |vim-markdown-follow-named-anchors|
19   10. Syntax extensions                        |vim-markdown-syntax-extensions|
20    1. LaTeX math                                      |vim-markdown-latex-math|
21    2. YAML Front Matter                        |vim-markdown-yaml-front-matter|
22    3. TOML Front Matter                        |vim-markdown-toml-front-matter|
23    4. JSON Front Matter                        |vim-markdown-json-front-matter|
24   11. Adjust new list item indent    |vim-markdown-adjust-new-list-item-indent|
25   12. Do not require .md extensions for Markdown links
26                 |vim-markdown-do-not-require-.md-extensions-for-markdown-links|
27   13. Auto-write when following link
28                                   |vim-markdown-auto-write-when-following-link|
29   14. Change default file extension
30                                    |vim-markdown-change-default-file-extension|
31   15. Do not automatically insert bulletpoints
32                         |vim-markdown-do-not-automatically-insert-bulletpoints|
33   16. Change how to open new files  |vim-markdown-change-how-to-open-new-files|
34  4. Mappings                                            |vim-markdown-mappings|
35  5. Commands                                            |vim-markdown-commands|
36  6. Credits                                              |vim-markdown-credits|
37  7. License                                              |vim-markdown-license|
38  8. References                                        |vim-markdown-references|
39
40 ===============================================================================
41                                                     *vim-markdown-introduction*
42 Introduction ~
43
44 Syntax highlighting, matching rules and mappings for the original Markdown [1]
45 and extensions.
46
47 ===============================================================================
48                                                     *vim-markdown-installation*
49 Installation ~
50
51 If you use Vundle [2], add the following line to your '~/.vimrc':
52 >
53   Plugin 'godlygeek/tabular'
54   Plugin 'plasticboy/vim-markdown'
55 <
56 The 'tabular' plugin must come _before_ 'vim-markdown'.
57
58 Then run inside Vim:
59 >
60   :so ~/.vimrc
61   :PluginInstall
62 <
63 If you use Pathogen [3], do this:
64 >
65   cd ~/.vim/bundle
66   git clone https://github.com/plasticboy/vim-markdown.git
67 <
68 To install without Pathogen using the Debian vim-addon-manager [4], do this:
69 >
70   git clone https://github.com/plasticboy/vim-markdown.git
71   cd vim-markdown
72   sudo make install
73   vim-addon-manager install markdown
74 <
75 If you are not using any package manager, download the tarball [5] and do this:
76 >
77   cd ~/.vim
78   tar --strip=1 -zxf vim-markdown-master.tar.gz
79 <
80 ===============================================================================
81                                                          *vim-markdown-options*
82 Options ~
83
84 -------------------------------------------------------------------------------
85                                                  *vim-markdown-disable-folding*
86 Disable Folding ~
87
88 Add the following line to your '.vimrc' to disable the folding configuration:
89 >
90   let g:vim_markdown_folding_disabled = 1
91 <
92 This option only controls Vim Markdown specific folding configuration.
93
94 To enable/disable folding use Vim's standard folding configuration.
95 >
96   set [no]foldenable
97 <
98 -------------------------------------------------------------------------------
99                                                *vim-markdown-change-fold-style*
100 Change fold style ~
101
102 To fold in a style like python-mode [6], add the following to your '.vimrc':
103 >
104   let g:vim_markdown_folding_style_pythonic = 1
105 <
106 Level 1 heading which is served as a document title is not folded.
107 'g:vim_markdown_folding_level' setting is not active with this fold style.
108
109 To prevent foldtext from being set add the following to your '.vimrc':
110 >
111   let g:vim_markdown_override_foldtext = 0
112 <
113 -------------------------------------------------------------------------------
114                                         *vim-markdown-set-header-folding-level*
115 Set header folding level ~
116
117 Folding level is a number between 1 and 6. By default, if not specified, it is
118 set to 1.
119 >
120   let g:vim_markdown_folding_level = 6
121 <
122 Tip: it can be changed on the fly with:
123 >
124   :let g:vim_markdown_folding_level = 1
125   :edit
126 <
127 -------------------------------------------------------------------------------
128                                     *vim-markdown-disable-default-key-mappings*
129 Disable Default Key Mappings ~
130
131 Add the following line to your '.vimrc' to disable default key mappings:
132 >
133   let g:vim_markdown_no_default_key_mappings = 1
134 <
135 You can also map them by yourself with '<Plug>' mappings.
136
137 -------------------------------------------------------------------------------
138                                       *vim-markdown-enable-toc-window-auto-fit*
139 Enable TOC window auto-fit ~
140
141 Allow for the TOC window to auto-fit when it's possible for it to shrink. It
142 never increases its default size (half screen), it only shrinks.
143 >
144   let g:vim_markdown_toc_autofit = 1
145 <
146 -------------------------------------------------------------------------------
147                        *vim-markdown-text-emphasis-restriction-to-single-lines*
148 Text emphasis restriction to single-lines ~
149
150 By default text emphasis works across multiple lines until a closing token is
151 found. However, it's possible to restrict text emphasis to a single line (i.e.,
152 for it to be applied a closing token must be found on the same line). To do so:
153 >
154   let g:vim_markdown_emphasis_multiline = 0
155 <
156 -------------------------------------------------------------------------------
157                                                *vim-markdown-syntax-concealing*
158 Syntax Concealing ~
159
160 Concealing is set for some syntax.
161
162 For example, conceal '[link text](link url)' as just 'link text'. Also,
163 '_italic_' and '*italic*' will conceal to just _italic_. Similarly '__bold__',
164 '**bold**', '___italic bold___', and '***italic bold***' will conceal to just
165 **bold**, **bold**, **_italic bold_**, and **_italic bold_** respectively.
166
167 To enable conceal use Vim's standard conceal configuration.
168 >
169   set conceallevel=2
170 <
171 To disable conceal regardless of 'conceallevel' setting, add the following to
172 your '.vimrc':
173 >
174   let g:vim_markdown_conceal = 0
175 <
176 To disable math conceal with LaTeX math syntax enabled, add the following to
177 your '.vimrc':
178 >
179   let g:tex_conceal = ""
180   let g:vim_markdown_math = 1
181 <
182 -------------------------------------------------------------------------------
183                                      *vim-markdown-fenced-code-block-languages*
184 Fenced code block languages ~
185
186 You can use filetype name as fenced code block languages for syntax
187 highlighting. If you want to use different name from filetype, you can add it
188 in your '.vimrc' like so:
189 >
190   let g:vim_markdown_fenced_languages = ['csharp=cs']
191 <
192 This will cause the following to be highlighted using the 'cs' filetype syntax.
193 >
194   ```csharp
195   ...
196   ```
197 <
198 Default is "['c++=cpp', 'viml=vim', 'bash=sh', 'ini=dosini']".
199
200 -------------------------------------------------------------------------------
201                                             *vim-markdown-follow-named-anchors*
202 Follow named anchors ~
203
204 This feature allows the 'ge' command to follow named anchors in links of the
205 form 'file#anchor' or just '#anchor', where file may omit the '.md' extension
206 as usual. Two variables control its operation:
207 >
208   let g:vim_markdown_follow_anchor = 1
209 <
210 This tells vim-markdown whether to attempt to follow a named anchor in a link
211 or not. When it is 1, and only if a link can be split in two parts by the
212 pattern '#', then the first part is interpreted as the file and the second one
213 as the named anchor. This also includes urls of the form '#anchor', for which
214 the first part is considered empty, meaning that the target file is the current
215 one. After the file is opened, the anchor will be searched.
216
217 Default is '0'.
218 >
219   let g:vim_markdown_anchorexpr = "'<<'.v:anchor.'>>'"
220 <
221 This expression will be evaluated substituting 'v:anchor' with a quoted string
222 that contains the anchor to visit. The result of the evaluation will become the
223 real anchor to search in the target file. This is useful in order to convert
224 anchors of the form, say, 'my-section-title' to searches of the form 'My
225 Section Title' or '<<my-section-title>>'.
226
227 Default is "''".
228
229 -------------------------------------------------------------------------------
230                                                *vim-markdown-syntax-extensions*
231 Syntax extensions ~
232
233 The following options control which syntax extensions will be turned on. They
234 are off by default.
235
236 -------------------------------------------------------------------------------
237                                                       *vim-markdown-latex-math*
238 LaTeX math ~
239
240 Used as '$x^2$', '$$x^2$$', escapable as '\$x\$' and '\$\$x\$\$'.
241 >
242   let g:vim_markdown_math = 1
243 <
244 -------------------------------------------------------------------------------
245                                                *vim-markdown-yaml-front-matter*
246 YAML Front Matter ~
247
248 Highlight YAML front matter as used by Jekyll or Hugo [7].
249 >
250   let g:vim_markdown_frontmatter = 1
251 <
252 -------------------------------------------------------------------------------
253                                                *vim-markdown-toml-front-matter*
254 TOML Front Matter ~
255
256 Highlight TOML front matter as used by Hugo [7].
257
258 TOML syntax highlight requires vim-toml [8].
259 >
260   let g:vim_markdown_toml_frontmatter = 1
261 <
262 -------------------------------------------------------------------------------
263                                                *vim-markdown-json-front-matter*
264 JSON Front Matter ~
265
266 Highlight JSON front matter as used by Hugo [7].
267
268 JSON syntax highlight requires vim-json [9].
269 >
270   let g:vim_markdown_json_frontmatter = 1
271 <
272 -------------------------------------------------------------------------------
273                                      *vim-markdown-adjust-new-list-item-indent*
274 Adjust new list item indent ~
275
276 You can adjust a new list indent. For example, you insert a single line like
277 below:
278 >
279   * item1
280 <
281 Then if you type 'o' to insert new line in vim and type '* item2', the result
282 will be:
283 >
284   * item1
285       * item2
286 <
287 vim-markdown automatically insert the indent. By default, the number of spaces
288 of indent is 4. If you'd like to change the number as 2, just write:
289 >
290   let g:vim_markdown_new_list_item_indent = 2
291 <
292 -------------------------------------------------------------------------------
293                 *vim-markdown-do-not-require-.md-extensions-for-markdown-links*
294 Do not require .md extensions for Markdown links ~
295
296 If you want to have a link like this '[link text](link-url)' and follow it for
297 editing in vim using the 'ge' command, but have it open the file "link-url.md"
298 instead of the file "link-url", then use this option:
299 >
300   let g:vim_markdown_no_extensions_in_markdown = 1
301 <
302 This is super useful for GitLab and GitHub wiki repositories.
303
304 Normal behaviour would be that vim-markup required you to do this '[link text
305 ](link-url.md)', but this is not how the Gitlab and GitHub wiki repositories
306 work. So this option adds some consistency between the two.
307
308 -------------------------------------------------------------------------------
309                                   *vim-markdown-auto-write-when-following-link*
310 Auto-write when following link ~
311
312 If you follow a link like this '[link text](link-url)' using the 'ge' shortcut,
313 this option will automatically save any edits you made before moving you:
314 >
315   let g:vim_markdown_autowrite = 1
316 <
317 -------------------------------------------------------------------------------
318                                    *vim-markdown-change-default-file-extension*
319 Change default file extension ~
320
321 If you would like to use a file extension other than '.md' you may do so using
322 the 'vim_markdown_auto_extension_ext' variable:
323 >
324   let g:vim_markdown_auto_extension_ext = 'txt'
325 <
326 -------------------------------------------------------------------------------
327                         *vim-markdown-do-not-automatically-insert-bulletpoints*
328 Do not automatically insert bulletpoints ~
329
330 Automatically inserting bulletpoints can lead to problems when wrapping text
331 (see issue #232 for details), so it can be disabled:
332 >
333   let g:vim_markdown_auto_insert_bullets = 0
334 <
335 In that case, you probably also want to set the new list item indent to 0 as
336 well, or you will have to remove an indent each time you add a new list item:
337 >
338   let g:vim_markdown_new_list_item_indent = 0
339 <
340 -------------------------------------------------------------------------------
341                                     *vim-markdown-change-how-to-open-new-files*
342 Change how to open new files ~
343
344 By default when following a link the target file will be opened in your current
345 buffer. This behavior can change if you prefer using splits or tabs by using
346 the 'vim_markdown_edit_url_in' variable. Possible values are 'tab', 'vsplit',
347 'hsplit', 'current' opening in a new tab, vertical split, horizontal split, and
348 current buffer respectively. Defaults to current buffer if not set:
349 >
350   let g:vim_markdown_edit_url_in = 'tab'
351 <
352 ===============================================================================
353                                                         *vim-markdown-mappings*
354 Mappings ~
355
356 The following work on normal and visual modes:
357
358                                                               *vim-markdown-gx*
359 - 'gx': open the link under the cursor in the same browser as the standard
360   'gx' command. '<Plug>Markdown_OpenUrlUnderCursor'
361
362   The standard 'gx' is extended by allowing you to put your cursor anywhere
363   inside a link.
364
365   For example, all the following cursor positions will work:
366 >
367   [Example](http://example.com)
368   ^  ^    ^^   ^       ^
369   1  2    34   5       6
370
371   <http://example.com>
372   ^  ^               ^
373   1  2               3
374 <
375   Known limitation: does not work for links that span multiple lines.
376
377                                                               *vim-markdown-ge*
378 - 'ge': open the link under the cursor in Vim for editing. Useful for
379   relative markdown links. '<Plug>Markdown_EditUrlUnderCursor'
380
381   The rules for the cursor position are the same as the 'gx' command.
382
383                                                               *vim-markdown-]]*
384 - ']]': go to next header. '<Plug>Markdown_MoveToNextHeader'
385
386                                                               *vim-markdown-[[*
387 - '[[': go to previous header. Contrast with ']c'.
388   '<Plug>Markdown_MoveToPreviousHeader'
389
390                                                               *vim-markdown-][*
391 - '][': go to next sibling header if any.
392   '<Plug>Markdown_MoveToNextSiblingHeader'
393
394                                                               *vim-markdown-[]*
395 - '[]': go to previous sibling header if any.
396   '<Plug>Markdown_MoveToPreviousSiblingHeader'
397
398                                                               *vim-markdown-]c*
399 - ']c': go to Current header. '<Plug>Markdown_MoveToCurHeader'
400
401                                                               *vim-markdown-]u*
402 - ']u': go to parent header (Up). '<Plug>Markdown_MoveToParentHeader'
403
404 This plugin follows the recommended Vim plugin mapping interface, so to change
405 the map ']u' to 'asdf', add to your '.vimrc':
406 >
407   map asdf <Plug>Markdown_MoveToParentHeader
408 <
409 To disable a map use:
410 >
411   map <Plug> <Plug>Markdown_MoveToParentHeader
412 <
413 ===============================================================================
414                                                         *vim-markdown-commands*
415 Commands ~
416
417 The following requires ':filetype plugin on'.
418
419                                                               *:HeaderDecrease*
420 - ':HeaderDecrease':
421
422   Decrease level of all headers in buffer: 'h2' to 'h1', 'h3' to 'h2', etc.
423
424   If range is given, only operate in the range.
425
426   If an 'h1' would be decreased, abort.
427
428   For simplicity of implementation, Setex headers are converted to Atx.
429
430                                                               *:HeaderIncrease*
431 - ':HeaderIncrease': Analogous to ':HeaderDecrease', but increase levels
432   instead.
433
434                                                                   *:SetexToAtx*
435 - ':SetexToAtx':
436
437   Convert all Setex style headers in buffer to Atx.
438
439   If a range is given, e.g. hit ':' from visual mode, only operate on the
440   range.
441
442                                                                  *:TableFormat*
443 - ':TableFormat': Format the table under the cursor like this [10].
444
445   Requires Tabular [11].
446
447   The input table _must_ already have a separator line as the second line of
448   the table. That line only needs to contain the correct pipes '|', nothing
449   else is required.
450
451                                                                          *:Toc*
452 - ':Toc': create a quickfix vertical window navigable table of contents with
453   the headers.
454
455   Hit '<Enter>' on a line to jump to the corresponding line of the markdown
456   file.
457
458                                                                         *:Toch*
459 - ':Toch': Same as ':Toc' but in an horizontal window.
460
461                                                                         *:Toct*
462 - ':Toct': Same as ':Toc' but in a new tab.
463
464                                                                         *:Tocv*
465 - ':Tocv': Same as ':Toc' for symmetry with ':Toch' and ':Tocv'.
466
467 ===============================================================================
468                                                          *vim-markdown-credits*
469 Credits ~
470
471 The main contributors of vim-markdown are:
472
473 - **Ben Williams** (A.K.A. **plasticboy**). The original developer of vim-
474   markdown. Homepage [12].
475
476 If you feel that your name should be on this list, please make a pull request
477 listing your contributions.
478
479 ===============================================================================
480                                                          *vim-markdown-license*
481 License ~
482
483 The MIT License (MIT)
484
485 Copyright (c) 2012 Benjamin D. Williams
486
487 Permission is hereby granted, free of charge, to any person obtaining a copy of
488 this software and associated documentation files (the "Software"), to deal in
489 the Software without restriction, including without limitation the rights to
490 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
491 of the Software, and to permit persons to whom the Software is furnished to do
492 so, subject to the following conditions:
493
494 The above copyright notice and this permission notice shall be included in all
495 copies or substantial portions of the Software.
496
497 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
498 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
499 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
500 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
501 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
502 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
503 SOFTWARE.
504
505 ===============================================================================
506                                                       *vim-markdown-references*
507 References ~
508
509 [1] http://daringfireball.net/projects/markdown/
510 [2] https://github.com/gmarik/vundle
511 [3] https://github.com/tpope/vim-pathogen
512 [4] http://packages.qa.debian.org/v/vim-addon-manager.html
513 [5] https://github.com/plasticboy/vim-markdown/archive/master.tar.gz
514 [6] https://github.com/klen/python-mode
515 [7] https://gohugo.io/content/front-matter/
516 [8] https://github.com/cespare/vim-toml
517 [9] https://github.com/elzr/vim-json
518 [10] http://www.cirosantilli.com/markdown-style-guide/#tables
519 [11] https://github.com/godlygeek/tabular
520 [12] http://plasticboy.com/
521
522 vim: ft=help