加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

vim中的多个自动命令

发布时间:2020-12-15 16:23:12 所属栏目:安全 来源:网络整理
导读:我在.vimrc中有一些部分,看起来像这样: autocmd Filetype ruby setlocal ts=2autocmd Filetype ruby setlocal sts=2autocmd Filetype ruby setlocal sw=2 现在看来我可以把它们转换为: autocmd Filetype ruby setlocal ts=2 sts=2 sw=2 但这里是我的问题
我在.vimrc中有一些部分,看起来像这样:
autocmd Filetype ruby setlocal ts=2
autocmd Filetype ruby setlocal sts=2
autocmd Filetype ruby setlocal sw=2

现在看来我可以把它们转换为:

autocmd Filetype ruby setlocal ts=2 sts=2 sw=2

但这里是我的问题:有一个vim方式有这样的结构吗?

<something mentioning Filetype ruby>
  setlocal ts=2
  setlocal sts=2
  ...
<end>

即,可以使用autocmd Filetype位以某种方式解决一组操作? (这是一个简单的例子,我真的要求更复杂的情况。)

你可以调用一个函数,如果你喜欢:
autocmd Filetype ruby call SetRubyOptions()
function SetRubyOptions()
    setlocal ts=2
    ...
endfunction

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读