Vim Markdown

  1. Github Vim Markdown
  2. Vim Markdown Filetype

Vim users can install either vim-prettier, which is Prettier specific, or Neoformat or ALE which are generalized lint/format engines with support for Prettier.

  • A Vim plugin for previewing markdown files in a browser. This plugin was designed to maintain focus on Vim but use Google Chrome to preview rendered markdown. Thus, everything is done in the background so you never have to leave vim.
  • For example: I have found the vim-pandoc-syntax plug-in particularly suitable for my highlighting needs. Nevertheless, I use the more general vim-markdown-folding for Markdown folding. By the way, only one flavour is allowed, separated by a dot, e.g.: filetype=markdown.pandoc.

How I Take Notes With Vim, Markdown, and Pandoc May 15, 2018 I’ve gone through quite a few revisions of my note-taking process and now that I’m in my final year of school, I think I’ve finally found a system that I’m going to stick with. GFM is a flavor of markdown, not a colorscheme. I think that vim-markdown is the plugin which works best for this markdown flavor (but I didn't test a lot of plugin). However if I may point out something: Trying to switch a research team to a modal editor like vim or neovim when they are used to a classical text editor and didn't ask for a change sounds like asking for trouble, (neo)vim has a.

Vim

See the vim-prettier readme for installation and usage instructions.

The best way to install Neoformat is with your favorite plugin manager for Vim, such as vim-plug:

Run :Neoformat or :Neoformat prettier in a supported file to run Prettier.

To have Neoformat run Prettier on save:

You can also make Vim format your code more frequently, by setting an autocmd for other events. Here are a couple of useful ones:

  • TextChanged: after a change was made to the text in Normal mode
  • InsertLeave: when leaving Insert mode

For example, you can format on both of the above events together with BufWritePre like this:

See :help autocmd-events in Vim for details.

It’s recommended to use a config file, but you can also add options in your .vimrc:

Each space in Prettier options should be escaped with .

ALE requires either Vim 8 or Neovim as ALE makes use of the asynchronous abilities that both Vim 8 and Neovim provide.

The best way to install ALE is with your favorite plugin manager for Vim, such as vim-plug:

You can find further instructions on the ALE repository.

ALE will try to use Prettier installed locally before looking for a global installation.

Enable the Prettier fixer for the languages you use:

ALE supports both linters and fixers. If you don’t specify which linters to run, all available tools for all supported languages will be run, and you might get a correctly formatted file with a bunch of lint errors. To disable this behavior you can tell ALE to run only linters you've explicitly configured (more info in the FAQ):

You can then run :ALEFix in a JavaScript or CSS file to run Prettier.

To have ALE run Prettier on save:

It’s recommended to use a config file, but you can also add options in your .vimrc:

Github Vim Markdown

Prettier extension for coc.nvim which requires neovim or vim8.1.Install coc.nvim with your favorite plugin manager, such as vim-plug:

And install coc-prettier by command:

Setup Prettier command in your init.vim or .vimrc

Vim Markdown Filetype

Update your coc-settings.json for languages that you want format on save.

coc-prettier have same configurations of prettier-vscode, open coc-settings.json by :CocConfig to get autocompletion support.

Running manually

If you want something really bare-bones, you can create a custom key binding. In this example, gp (mnemonic: 'get pretty') is used to run prettier (with options) in the currently active buffer:

Note that if there’s a syntax error in your code, the whole buffer will be replaced with an error message. You’ll need to press u to get your code back.

Another disadvantage of this approach is that the cursor position won’t be preserved.