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

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