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