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