Open current file in web browser in Vim

前端 未结 9 573
自闭症患者
自闭症患者 2020-12-24 15:01

I\'d like to be able to send the HTML file I\'m currently editing in vim to my web browser, Chrome. I\'m running Linux.

This gets me very close:

9条回答
  •  春和景丽
    2020-12-24 15:33

    Here are various tips on previewing files in your browser from Linux, Windows, and Mac OS X. Preview current HTML file

    This mapping allows you to use a browser to preview the HTML file currently being edited.

     nnoremap  :silent updatesilent !firefox %:p &
    

    If necessary, the current file is saved, then Firefox is used to open the file. Replace "firefox" with the name of another browser if wanted, such as "chromium-browser".

    So as the question states that Chrome is the desired browser, then add this to your vimrc:

    nnoremap  :silent updatesilent !google-chrome %:p &
    

    As well as answer the OP, I wanted to share this link for those that reached this question in search of Windows and Mac OS X support.

提交回复
热议问题