[英]Sublime Text 2 -> Vim, How do I open html file in Chrome?
Just getting started with Vim and am writing a basic HTML file. 刚开始使用Vim并正在编写一个基本的HTML文件。 In SublimeText you could just right click and open in browser, but i'm having trouble finding how to do the same with Vim. 在SublimeText中你可以右键单击并在浏览器中打开,但我很难找到如何对Vim做同样的事情。 I have Ubuntu and I want to preview the code in Chrome. 我有Ubuntu,我想在Chrome中预览代码。
Thanks! 谢谢!
You can use :!
你可以使用:!
to execute external commands within vim (see :help :!
). 在vim中执行外部命令(参见:help :!
)。 The %
sign in an :ex
command expands to the current file name (see :help :_%
). an :ex
in命令中的%
符号将扩展为当前文件名(请参阅:help :_%
)。 That being said, you can use the following to first save the file and then open it in the browser of your choice 话虽这么说,您可以使用以下内容首先保存文件,然后在您选择的浏览器中打开它
:w|!google-chrome %
If you'd rather use firefox or chromium, use firefox
or chromium
, respectively, in place of google-chrome
. 如果你想用Firefox或铬,使用firefox
或chromium
,分别代替google-chrome
。 If you're on mac or linux you could also use the open
or xdg-open
commands, respectively, to open the file in its default application. 如果您使用的是mac或linux,则还可以分别使用open
或xdg-open
命令在其默认应用程序中打开该文件。 Don't want to type that out every time? 不想每次打出来吗? Make your own command or mapping in your .vimrc. 在.vimrc中创建自己的命令或映射。
command! ViewInBrowser :w|!google-chrome %
nnoremap <leader>b :ViewInBrowser<cr>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.