Open current file in web browser in Vim

前端 未结 9 574
自闭症患者
自闭症患者 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:35

    For windows7 x64, - F2 to open current file, - F3 to lookup current cword under cursor.

    for g:chrome_exe in [
        \'C:\Progra~2\Google\Chrome\Application\chrome.exe',
        \'C:\Progra~1\Google\Chrome\Application\chrome.exe',
        \'C:\Progra~1\Google\Chrome\Applic~1\chrome.exe',
        \'C:\Users\'.$USERNAME.'\AppData\Local\Google\Chrome\Application\chrome.exe' 
        \]
        if !filereadable(g:chrome_exe)
            continue
        endif
        let g:google_url='https://www.google.com/search?oq=&gws_rd=cr&dcr=0&ei=0&q='
        :nmap    :exe ":!start ".g:chrome_exe." --user-data-dir=%TEMP%/chrome-vim-sandbox file:///".expand("%:p")
        :nmap    :exe ":!start ".g:chrome_exe." --user-data-dir=%TEMP%/chrome-vim-sandbox ".g:google_url.expand("")
        break
    endfor 
    

提交回复
热议问题