简体   繁体   English

Sublime Text 2 - > Vim,如何在Chrome中打开html文件?

[英]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或铬,使用firefoxchromium ,分别代替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,则还可以分别使用openxdg-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.

相关问题 如何直接在Chrome中运行在Sublime Text中创建的html文件? - How to run the html file created in Sublime Text in Chrome directly? 如何使用 Sublime Text 2 重新格式化 HTML 代码? - How do I reformat HTML code using Sublime Text 2? 如何在Sublime Text 3中启用智能HTML标签缩进? - How do I enable smart HTML tag indenting in Sublime Text 3? 我在 github 上有这些.html 文件,但我没有用崇高的文本打开它们 3. 我该怎么做? 我可以请逐步说明 - I have these .html files on github and I wasnt to open them in sublime text 3. how do I do so? Can I please get step by step instructions 如何在Python中打开HTML文件 - How do I open an HTML file in Python 您如何将chrome浏览器与Sublime文本集成在一起以实现更好的工作流程 - How do you integrate chrome browser with sublime text for a better workflow 在Vim中,如何在浏览器中打开html文件而不创建新标签页? - In Vim, how do you open an html file in a browser without creating a new tab? 如何以崇高的文本(Mac)从 git 存储库打开文件? - How to open file from git repository in sublime text (Mac)? 如何在Sublime Text 3主题中设置自定义HTML标签突出显示? - How do I set custom HTML tag highlighting in a Sublime Text 3 theme? 您如何在Google Chrome中打开HTML? - How do you open html in google chrome?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM