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

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