在Mac上,我会用
:w | !open %
xdg-open:许多Linux发行版
cygstart:WINDOWS与Cygwin
cmd /c start:Windows
如果你想有一个快捷方式,然后像
:nmap :w !open %
讲一下你的vimrc文件。如果你想要的东西跨平台工作,那么你可以借这个功能(不过从名字下降drupal#)从https://drupal.org/project/vimrc:
" @function drupal#OpenCommand() {{{
" Return a string that can be used to open URL's (and other things).
" Usage:
" let open = drupal#OpenCommand()
" if strlen(open) | execute '!' . open 'http://example.com' | endif
" @see http://www.dwheeler.com/essays/open-files-urls.html
function! drupal#OpenCommand() " {{{
if has('win32unix') && executable('cygstart')
return 'cygstart'
elseif has('unix') && executable('xdg-open')
return 'xdg-open'
elseif (has('win32') || has('win64')) && executable('cmd')
return 'cmd /c start'
elseif (has('macunix') || has('unix') && system('uname') =~ 'Darwin')
\ && executable('open')
return 'open'
else
return ''
endif
endfun " }}} }}}