Open current file in Chrome with Vim
Hold on Cowboy
This blog post is pretty old. Be careful with the information you find in here. The Times They Are A-Changin'
Most of the time when I’m working on a Markdown document like a README, I want to preview it in Chrome as markdown. Perhaps I’m working on an HTML document and want to preview it in Chrome. It would be a real pain to go to Chrome and then look for the file I’m working on. Luckily Vim makes this really easy.
The Setup
Add this to your .vimrc
" Open up current file in chrome
nmap <silent> <leader>ch :exec 'silent !open -a "Google Chrome" % &'
(Optional) Add a Markdown viewer to Chrome. I use Markdown Preview Plus.
Now in Vim you just need to enter these commands in Normal mode (hint: my <leader>
is ,
)
,ch[Enter]
That’s all there is to this. It allows you to simply open the current file in Chrome.