gpt4 book ai didi

vim - 如何使用 Vim 在浏览器中预览 html 文件?任何键盘快捷键?

转载 作者:行者123 更新时间:2023-12-02 15:33:47 25 4
gpt4 key购买 nike

我是 Vim 世界的新手。我想使用 Vim 进行 Web 开发。任何人都知道如何在浏览器中显示您的 html 文件,有任何快捷方式吗?谢谢

最佳答案

在 Mac 上,我会使用

:w | !open %

在其他系统上,您可以使用(由 http://www.dwheeler.com/essays/open-files-urls.html 提供)代替 open

  • xdg-open:许多 Linux 发行版
  • cygstart:带有 Cygwin 的 Windows
  • cmd/c start: Windows

如果你想要一个快捷方式,那么添加类似的东西

:nmap <F5> :w <Bar> !open %<CR>

到你的 vimrc 文件。如果你想要跨平台工作的东西,那么你可以从 https://drupal.org/project/vimrc 借用这个功能(但从名称中删除 drupal#) :

" @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 " }}} }}}

关于vim - 如何使用 Vim 在浏览器中预览 html 文件?任何键盘快捷键?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21702726/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com