Flo*_*nt2 6 browser vim integration macvim
从 MacVim 是否有命令可以在 Web 浏览器中打开当前编辑的 HTML 文件?
pet*_*eth 15
只需做一次,您就可以
:!open %
Run Code Online (Sandbox Code Playgroud)
它将open以当前文件的路径作为参数调用 shell 命令。我自己不使用 Mac,但open对我来说似乎合适。如果不是,请替换为您希望打开文件的任何程序。
当然你可以绑定一个键,如果你经常需要它:
:map <silent> <F5> :!open %<CR>
Run Code Online (Sandbox Code Playgroud)
你可能想要
:set nowarn
Run Code Online (Sandbox Code Playgroud)
抑制有关未保存文件更改的警告。
看:
:help :!:help cmdline-special:help 'warn'请注意,您可以使用 Vim 脚本编写任意复杂的内容。例如,此函数可让您使用中间文件查看当前未保存的更改:
function! BrowserPreview()
if &modified
let tmpfile = tempname()
execute "silent write " . tmpfile
call system("firefox " . shellescape(tmpfile))
if delete(tmpfile) != 0
echoerr "could not remove " . tmpfile
endif
else
call system("firefox " . shellescape(expand("%:p")))
endif
endfunction
map <silent> <F5> :call BrowserPreview()<CR>
Run Code Online (Sandbox Code Playgroud)
(如果之前有效,请替换两次出现的firefoxwith open。)
| 归档时间: |
|
| 查看次数: |
3895 次 |
| 最近记录: |