- CSS 88.7%
- Vim Script 11.3%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
The old 2018 grid predated the highlighting themes. New image shows github, solarized-light and solarized-dark side by side, rendered at 2x with current pandoc and CSS. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
| autoload | ||
| css | ||
| doc | ||
| ftplugin | ||
| highlight | ||
| screenshots | ||
| CLAUDE.md | ||
| LICENSE | ||
| README.md | ||
nvim-markdown-preview
Markdown preview in the browser using pandoc and live-server through Neovim's job-control API.
This is a maintained fork of davidgranstrom/nvim-markdown-preview, which is no longer maintained. Report issues and send changes to git.bnor.org/benno/nvim-markdown-preview.
Usage
Open a markdown file in Neovim and run :MarkdownPreview. The preview opens in a new browser tab which will be reloaded whenever you :write the buffer. If you accidentally close your browser tab or want to change the theme just run the command again. The file needs to be written to disk before you can start the preview.
Features
- Asynchronous
- Produces "standalone" html files (injected css)
- Custom themes (
github,solarized-dark,solarized-light) - Auto-reloads browser tab on save
- Serves assets from the markdown file's directory (embed pictures in your markdown etc.)
- Any pandoc input format via
g:nvim_markdown_preview_format(defaultgfm) - KaTeX for formatting LaTeX math
- Syntax highlighting from the Kate Editor themes
Requirements
- Neovim (the plugin uses Neovim's job control and does not work in Vim)
pandoclive-server(Node.js)
pandoc and live-server executables should be installed and accessible in your $PATH.
Pandoc
Pandoc should be available in most Linux distributions and on macOS via brew and Windows via chocolatey.
On macOS using Homebrew:
brew install pandoc
For Linux:
-
Ubuntu
sudo apt install pandoc -
Fedora
sudo dnf install pandoc
For Windows:
Either download the executable or get it with Chocolatey
choco install pandoc
For other systems please see the links in the description on how to install.
live-server
Assuming you have Node.js installed:
npm install -g @compodoc/live-server
Use this fork rather than the original live-server package: the original is unmaintained and has known security vulnerabilities (see the historical upstream issue).
Installation
vim.pack (Neovim 0.12+)
Add this to your init.lua:
vim.pack.add({ 'https://git.bnor.org/benno/nvim-markdown-preview' })
The plugin is installed on the next start of Neovim. Update it with :lua vim.pack.update().
vim-plug
If you are using vim-plug
Plug 'https://git.bnor.org/benno/nvim-markdown-preview.git'
source the file (:source %) (or restart Neovim) and then run :PlugInstall
Documentation
Usage
There are two commands:
:MarkdownPreview [theme] Starts the browser preview of the current file.
Optional argument to select a theme
(<Tab> completes theme names).
The available themes are currently:
* github
* solarized-light
* solarized-dark
:MarkdownPreviewStop Stops the preview: shuts down live-server and
stops regenerating the preview on write.
Customization
Set this variable in your config to specify a default theme for the preview
(let g:… in init.vim, or vim.g.… = … in init.lua).
The default is the GitHub theme.
let g:nvim_markdown_preview_theme = 'solarized-light'
Set this variable to specify the pandoc input format (--format/-f) option.
The default is gfm (GitHub flavored markdown).
let g:nvim_markdown_preview_format = 'markdown'
Take a look at :help nvim-markdown-preview for complete documentation and examples.
Screenshots
Q & A
Q: Why doesn't the preview update in real-time while I type in Neovim?
A: This plugin simply doesn't work like that. It only aims to provide some live update capabilities around what is essentially :w !pandoc % -o /tmp/file.html
Q: I want the preview tab to open automatically without typing :MarkdownPreview
A: Sure, use an autocmd like:
autocmd FileType markdown MarkdownPreview
Or the <Plug> mapping to bind it to the key of your choice
nmap <cr> <plug>(nvim-markdown-preview)
Q: Can I preview two markdown files at the same time?
A: No. There is one preview per Neovim session. Running :MarkdownPreview in another buffer takes the preview over, and from then on only that buffer updates it on :write.
Q: Why aren't my unsaved changes shown?
A: The preview is rendered from the file on disk, not from the buffer. :write the buffer to update it.
License
GPL v3
nvim-markdown-preview
Copyright (C) 2018 David Granström
Copyright (C) 2026 Benno Richters
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
