A Vim plugin for previewing Markdown files using glow in a synchronized vertical split with beautiful color rendering.
This plugin is a Vimscript reimplementation of the original idea from glow.nvim, bringing the same functionality to classic Vim users with enhanced color support.
- π Live Preview: Real-time Markdown rendering using glow
- π¨ Rich Colors: Custom ANSI renderer with beautiful syntax highlighting
- π Synchronized Scrolling: Preview window follows your cursor position
- β‘ Auto-update: Preview updates on text changes
- πͺ Split View: Clean vertical split layout
- β¨οΈ Simple Commands: Easy-to-use commands and key mappings
- π― Pure Vimscript: No external dependencies beyond glow
- Vim 8.0+ or Neovim
- glow binary installed
set termguicolorsfor color support
Plug 'Maxim4711/glow.vim'Plugin 'Maxim4711/glow.vim'cd ~/.vim/bundle
git clone https://github.com/Maxim4711/glow.vim.git- Download the plugin files
- Copy the directories to your Vim configuration:
plugin/glow.vimβ~/.vim/plugin/autoload/glow.vimβ~/.vim/autoload/doc/glow.txtβ~/.vim/doc/
brew install glow# Arch Linux
sudo pacman -S glow
# Ubuntu/Debian (via snap)
sudo snap install glow
# Or download from GitHub releases
curl -s https://api.github.com/repos/charmbracelet/glow/releases/latest | grep browser_download_url | cut -d '"' -f 4 | grep linux | wget -i -Download from Glow releases
- Enable colors in your
.vimrc:
set termguicolors
let g:glow_use_colors = 1
let g:glow_render_colors = 1- Open a markdown file and toggle preview:
:edit README.md
<Leader>p- Enjoy beautiful colored markdown preview!
| Command | Description |
|---|---|
:GlowToggle |
Toggle the preview window |
:GlowOpen |
Open the preview window |
:GlowClose |
Close the preview window |
:GlowToggleSync |
Toggle scroll synchronization |
| Key | Command |
|---|---|
<Leader>p |
Toggle preview window |
<Leader>P |
Toggle scroll synchronization |
Add these options to your .vimrc:
" Basic configuration for colored preview
set termguicolors " Required for colors
let g:glow_use_colors = 1 " Enable ANSI colors from glow
let g:glow_render_colors = 1 " Render colors in Vim
" Optional customization
let g:glow_binary_path = 'glow' " Path to glow binary (default: 'glow')
let g:glow_width = 100 " Preview width in characters (default: 80)
let g:glow_style = 'dark' " Glow style theme (default: 'auto')
let g:glow_pager = 0 " Enable pager mode (default: 0)
let g:glow_sync_scroll = 1 " Enable scroll sync (default: 1)
" Disable default key mappings
let g:glow_disable_default_mappings = 1The plugin uses a custom ANSI renderer that creates beautiful colors for different markdown elements:
- Headers (
# Header) β Bright red/pink with bold formatting - Bold text (
**bold**) β Bright green with bold formatting - Italic text (
*italic*) β Light blue with italic formatting - Code blocks (
`code`) β Yellow highlighting - Links (
[text](url)) β Purple with underline
| Style | Description |
|---|---|
'auto' |
Automatically detect terminal theme (default) |
'dark' |
Dark theme with bright colors |
'light' |
Light theme |
'notty' |
Plain text without colors |
If you disabled default mappings, you can create your own:
let g:glow_disable_default_mappings = 1
" Custom mappings
nnoremap <silent> <F5> :GlowToggle<CR>
nnoremap <silent> <F6> :GlowToggleSync<CR>
nnoremap <silent> <C-p> :GlowOpen<CR>- Preview Generation: Captures your Markdown buffer content and passes it to the
glowbinary withFORCE_COLOR=1 - ANSI Processing: Custom Vimscript ANSI renderer parses color sequences and applies them as Vim highlighting
- Split Management: Creates and manages a vertical split window for the preview
- Synchronization: Calculates relative scroll positions to keep source and preview in sync
- Auto-updates: Uses Vim's autocmd system to update the preview on text changes
This plugin features a custom ANSI renderer built in pure Vimscript that:
- β Parses glow's ANSI color sequences without external dependencies
- β Maps formatting to Vim highlight groups for optimal display
- β
Handles complex sequences like
;;1mthat other tools struggle with - β Provides rich syntax highlighting for all markdown elements
- β Works with any terminal and colorscheme
Unlike solutions that depend on external plugins like AnsiEsc, this renderer is:
- Faster: No external command execution
- More reliable: No version compatibility issues
- More customizable: Easy to modify colors and formatting
- Lighter: No additional plugin dependencies
Error: Glow binary not found at: glow
Solution: Install glow or set the correct path:
let g:glow_binary_path = '/path/to/glow'Solution: Enable termguicolors and color rendering:
set termguicolors
let g:glow_use_colors = 1
let g:glow_render_colors = 1- Ensure you're editing a
.mdfile - Check if glow is executable:
:!which glow - Try manually refreshing:
:GlowClosethen:GlowOpen
- Toggle sync off and on:
:GlowToggleSync - Check that both windows are visible
The custom ANSI renderer is optimized for performance:
- Minimal overhead: Only processes visible content
- Efficient highlighting: Uses Vim's native
matchadd()system - Smart caching: Reuses highlight groups across updates
- No external calls: Everything happens within Vim
This plugin is inspired by and reimplements the functionality of glow.nvim by @ellisonleao. The original Lua implementation for Neovim provided the foundation for this Vimscript version.
Special thanks to:
- Charm for the excellent
glowterminal markdown reader - The original
glow.nvimcontributors for the plugin concept - The Vim community for the inspiration to create a pure Vimscript solution
MIT License - see LICENSE file for details.
Issues and pull requests are welcome! Please feel free to contribute improvements or report bugs.