]> 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:

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