preservim / vim-markdown

Markdown Vim Mode
4.64k stars 521 forks source link
markdown syntax-highlighting vim

Vim Markdown

Vint Vader

Syntax highlighting, matching rules and mappings for the original Markdown and extensions.

  1. Installation
  2. Basic usage
  3. Options
  4. Mappings
  5. Commands
  6. Credits
  7. License

Installation

If you use Vundle, add the following lines to your ~/.vimrc:

Plugin 'godlygeek/tabular'
Plugin 'preservim/vim-markdown'

The tabular plugin must come before vim-markdown.

Then run inside Vim:

:so ~/.vimrc
:PluginInstall

If you use Pathogen, do this:

cd ~/.vim/bundle
git clone https://github.com/preservim/vim-markdown.git

To install without Pathogen using the Debian vim-addon-manager, do this:

git clone https://github.com/preservim/vim-markdown.git
cd vim-markdown
sudo make install
vim-addon-manager install markdown

If you are using a package manager with semver support (like lazy.nvim) make sure you are following the master branch (see https://github.com/preservim/vim-markdown/issues/616).

If you are not using any package manager, download the tarball and do this:

cd ~/.vim
tar --strip=1 -zxf vim-markdown-master.tar.gz

Basic usage

Folding

Folding is enabled for headers by default.

The following commands are useful to open and close folds:

Options are available to disable folding or change folding style.

Try :help fold-expr and :help fold-commands for details.

Concealing

Concealing is set for some syntax such as bold, italic, code block and link.

Concealing lets you conceal text with other text. The actual source text is not modified. If you put your cursor on the concealed line, the conceal goes away.

Options are available to disable or change concealing.

Try :help concealcursor and :help conceallevel for details.

Options

Disable Folding

Change fold style

Set header folding level

Disable Default Key Mappings

Enable TOC window auto-fit

Text emphasis restriction to single-lines

Syntax Concealing

Fenced code block languages

Follow named anchors

Syntax extensions

The following options control which syntax extensions will be turned on. They are off by default.

LaTeX math

YAML Front Matter

TOML Front Matter

JSON Front Matter

Strikethrough

Adjust new list item indent

Do not require .md extensions for Markdown links

Auto-write when following link

Change default file extension

Do not automatically insert bulletpoints

Change how to open new files

Borderless tables

Mappings

The following work on normal and visual modes:

This plugin follows the recommended Vim plugin mapping interface, so to change the map ]u to asdf, add to your .vimrc:

map asdf <Plug>Markdown_MoveToParentHeader

To disable a map use:

map <Plug> <Plug>Markdown_MoveToParentHeader

Commands

The following requires :filetype plugin on.

Credits

The main contributors of vim-markdown are:

If you feel that your name should be on this list, please make a pull request listing your contributions.

License

The MIT License (MIT)

Copyright (c) 2012 Benjamin D. Williams

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.