A Simple Tip for Previewing Markdown in Typora from Vim
Easily preview Markdown files you're editing in Vim on macOS using the familiar Typora interface. No plugins or complicated setup required. Just add one line to your .vimrc.
- Simple — Just one line in your
.vimrc - No plugins required — Uses the built-in macOS
opencommand - No auto-save — File saving remains under your control in Vim
- Customizable — Can be adapted to other apps that support Markdown
- macOS 27 Golden Gate
- VIM - Vi IMproved 9.1
- Typora Version 1.0
Add the following line to your ~/.vimrc:
command! Mdp silent call system('open -a "Typora" ' . shellescape(expand('%:p')))To apply the changes, restart Vim or run :source ~/.vimrc.
vim_typora_preview_demo.mp4
- Open a Markdown file in Vim.
- Enter
:Mdpin Vim's command-line mode. - Typora will open and display the current file.
Note: Unsaved changes in Vim will not appear in Typora. Save the file in Vim when needed.
To use another app instead of Typora, replace "Typora" with the name of your preferred app.
command! Mdp silent call system('open -a "Typora" ' . shellescape(expand('%:p')))
You can also change the command name Mdp. However, Vim user-defined commands must begin with an uppercase letter.
This command uses the macOS open -a command to pass the current file in Vim to the specified application.
command! Mdp— Defines a custom Vim commandsilent— Suppresses messages during executionsystem()— Executes an external commandopen -a— Opens a file with the specified applicationexpand('%:p')— Gets the absolute path of the current fileshellescape()— Safely escapes the file path for shell execution
Vim Typora Preview is released under the MIT License.
Copyright © 2026 fix
