【问题标题】:Why if can expand instead of ifee in vim-snippets and ultisnips?为什么 if 可以在 vim-snippets 和 ultisnips 中扩展而不是 ifee?
【发布时间】:2019-08-29 18:36:24
【问题描述】:

我已经用插件管理器安装了vim-snippetsultisnips--pathogen这种方式。

cd ~/.vim/bundle
sudo git clone https://github.com/honza/vim-snippets.git
cd ~/.vim/bundle && git clone git://github.com/SirVer/ultisnips.git

.vimrc中设置配置。

execute pathogen#infect()
execute pathogen#helptags()
syntax on
filetype plugin indent on
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
let g:UltiSnipsSnippetDirectories=['/home/debian9/.vim/UltiSnips']

我在 python.sn-ps 中列出了 if ife ifee 结构。

cat .vim/bundle/vim-snippets/UltiSnips/python.snippets
snippet if "If" b
if ${1:condition}:
    ${2:${VISUAL:pass}}
endsnippet

snippet ife "If / Else" b
if ${1:condition}:
    ${2:${VISUAL:pass}}
else:
    ${3:pass}
endsnippet

snippet ifee "If / Elif / Else" b
if ${1:condition}:
    ${2:${VISUAL:pass}}
elif ${3:condition}:
    ${4:pass}
else:
    ${5:pass}
endsnippet

现在是时候用 vim 编辑 test.py 文件了。

输入#!再按tab可以展开成:

#!/usr/bin/env python3

输入if再按tab可以展开成:

if condition:

为什么在我的 vim 中输入 ifee 并按 tab 可以扩展为空?

【问题讨论】:

    标签: vim plugins ultisnips vim-snipmate


    【解决方案1】:

    您显示的文件 .vim/bundle/vim-snippets/UltiSnips/python.snippets 不包含在您在 vimrc 中配置的 ultisnips 目录中 (/home/debian9/.vim/UltiSnips)。

    你可以试试:

    • 更改您的配置:

      let g:UltiSnipsSnippetDirectories=['/home/debian9/.vim/bundle/vim-snippets/UltiSnips']
      
    • 或者,检查文件/home/debian9/.vim/UltiSnips/python.snippets 以查看是否定义了正确的sn-ps。

    【讨论】:

      猜你喜欢
      • 2020-11-13
      • 2020-09-07
      • 1970-01-01
      • 2016-01-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-20
      • 2011-04-13
      相关资源
      最近更新 更多