No description
  • CSS 88.7%
  • Vim Script 11.3%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Benno Richters 542ba0f03b screenshots: regenerate theme grid with syntax highlighting
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>
2026-10-04 13:10:03 +02:00
autoload add :MarkdownPreviewStop command 2026-10-04 10:27:44 +02:00
css css/github: restore grey code block background 2026-10-04 13:10:03 +02:00
doc README, help: present as maintained fork and fix outdated text 2026-10-04 10:36:38 +02:00
ftplugin add :MarkdownPreviewStop command 2026-10-04 10:27:44 +02:00
highlight Add syntax highlighting themes (#6) 2021-12-01 15:30:14 +01:00
screenshots screenshots: regenerate theme grid with syntax highlighting 2026-10-04 13:10:03 +02:00
CLAUDE.md CLAUDE.md: push without asking 2026-10-04 10:28:51 +02:00
LICENSE Add LICENSE 2018-05-10 19:49:39 +02:00
README.md README, help: present as maintained fork and fix outdated text 2026-10-04 10:36:38 +02:00

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 (default gfm)
  • 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)
  • pandoc
  • live-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/>.