Ⅰ. 插件描述
Instant Markdown previews from VIm!Ⅱ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'euclio/vim-instant-markdown-please-everybody'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'euclio/vim-instant-markdown-please-everybody'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'euclio/vim-instant-markdown-please-everybody'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/euclio/vim-instant-markdown
Ⅳ. 文档说明
vim-instant-markdown
Want to instantly preview finnicky markdown files, but don't want to leave your favorite editor, or have to do it in some crappy browser textarea? vim-instant-markdown is your friend! When you open a markdown file in vim, a browser window will open which shows the compiled markdown in real-time, and closes once you close the file in vim.
As a bonus, github-flavored-markdown is supported, and styles used while previewing are the same as those github uses!
Installation
You first need to have node.js with npm installed. Then:
[sudo] npm -g install instant-markdown-dIf you're on Linux, ensure the following packages are installed:
xdg-utilscurlnodejs-legacy(for Debian-based systems)
- Copy the
after/ftplugin/markdown/instant-markdown.vimfile from this repo into your~/.vim/after/ftplugin/markdown/(creating directories as necessary), or follow your vim package manager's instructions. - Ensure you have the line
filetype plugin onin your.vimrc - Open a markdown file in vim and enjoy!
Configuration
g:instant_markdown_slow
By default, vim-instant-markdown will update the display in realtime. If that taxes your system too much, you can specify
let g:instant_markdown_slow = 1before loading the plugin (for example place that in your ~/.vimrc). This will cause vim-instant-markdown to only refresh on the following events:
- No keys have been pressed for a while
- A while after you leave insert mode
- You save the file being edited
g:instant_markdown_autostart
By default, vim-instant-markdown will automatically launch the preview window when you open a markdown file. If you want to manually control this behavior, you can specify
let g:instant_markdown_autostart = 0in your .vimrc. You can then manually trigger preview via the command :InstantMarkdownPreview. This command is only available inside markdown buffers and when the autostart option is turned off.
Supported Platforms
OSX and Unix/Linuxes*.
*: One annoyance in Linux is that there's no way to reliably open a browser page in the background, so you'll likely have to manually refocus your vim session everytime you open a Markdown file. If you have ideas on how to address this I'd love to know!
FAQ
It's not working!
- Make sure
instant-markdown-dwas installed as a global module (e.g. usingnpm -g install) - If you're on OSX and are using zsh, try to add
set shell=bash\ -iin your.vimrcto set interactive bash as the default vim shell. (See this issue)
etc.
If you're curious, the code for the mini-server component for this plugin can be found at http://github.com/suan/instant-markdown-d. A plugin can easily be written for any editor to interface with the server to get the same functionality found here.