ultisnips扩展不起作用,我无法弄清楚为什么

时间:2014-03-26 18:58:55

标签: vim ultisnips

我在排除故障时几乎删除了所有内容。 Vim打开时没有错误:UltiSnipsEdit有效,但当我输入剪辑<tab>时,会输入一个实际的标签。我目前的vimrc。这些配置已经从github复制到了Vundle和UltiSnips。

set nocompatible
filetype off

"set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()

" let Vundle manage Vundle, required
Plugin 'gmarik/vundle'
Plugin 'SirVer/ultisnips'

filetype plugin indent on

let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<c-b>"
let g:UltiSnipsJumpBackwardTrigger="<c-z>"

" If you want :UltiSnipsEdit to split your window.
let g:UltiSnipsEditSplit="vertical"

详细的imap <tab>

i  <Tab>       * <C-R>=UltiSnips#ExpandSnippet()<CR>
    Last set from ~/.vim/bundle/ultisnips/autoload/UltiSnips/map_keys.vim

:版本

:version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jan 10 2014 09:33:13)
Included patches: 1-135
Compiled by Arch Linux
Huge version with GTK2 GUI.  Features included (+) or not (-):
+acl             +cindent         +conceal         +digraphs        +farsi           +gettext         +libcall         +mksession       +mouse_netterm   -mzscheme        +profile         +scrollbind      +syntax          +textobjects     +visualextra     +X11
+arabic          +clientserver    +cryptv          +dnd             +file_in_path    -hangul_input    +linebreak       +modify_fname    +mouse_sgr       +netbeans_intg   +python          +signs           +tag_binary      +title           +viminfo         -xfontset
+autocmd         +clipboard       +cscope          -ebcdic          +find_in_path    +iconv           +lispindent      +mouse           -mouse_sysmouse  +path_extra      -python3         +smartindent     +tag_old_static  +toolbar         +vreplace        +xim
+balloon_eval    +cmdline_compl   +cursorbind      +emacs_tags      +float           +insert_expand   +listcmds        +mouseshape      +mouse_urxvt     +perl            +quickfix        -sniff           -tag_any_white   +user_commands   +wildignore      +xsmp_interact
+browse          +cmdline_hist    +cursorshape     +eval            +folding         +jumplist        +localmap        +mouse_dec       +mouse_xterm     +persistent_undo +reltime         +startuptime     -tcl             +vertsplit       +wildmenu        +xterm_clipboard
++builtin_terms  +cmdline_info    +dialog_con_gui  +ex_extra        -footer          +keymap          +lua             +mouse_gpm       +multi_byte      +postscript      +rightleft       +statusline      +terminfo        +virtualedit     +windows         -xterm_save
+byte_offset     +comments        +diff            +extra_search    +fork()          +langmap         +menu            -mouse_jsbterm   +multi_lang      +printer         +ruby            -sun_workshop    +termresponse    +visual          +writebackup     -xpm
   system vimrc file: "/etc/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "/etc/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -pthread -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/libdrm -I/usr/include/libpng16 -I/usr/inclu
de/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/freetype2  -D_FORTIFY_SOURCE=2  -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --
param=ssp-buffer-size=4 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc   -L. -Wl,-O1,--sort-common,--as-needed,-z,relro -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-E -Wl,-rpath,/usr/lib/perl5/core_perl/CORE  -Wl,-O1,--sort-common,--as-needed,-z,relro -L/usr/local/lib -Wl,--as-needed -o vim   -lgtk-x11-2.0 -lgdk-x11-2.0 -l
pangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lfontconfig -lfreetype  -lSM -lICE -lXt -lX11 -lXdmcp -lSM -lICE  -lm -lncurses -lelf -lnsl   -lacl -lattr -lgpm -ldl  -L/usr/lib -llua -Wl,-E -Wl,-rpath,/usr/li
b/perl5/core_perl/CORE -Wl,-O1,--sort-common,--as-needed,-z,relro -fstack-protector -L/usr/local/lib  -L/usr/lib/perl5/core_perl/CORE -lperl -lnsl -ldl -lm -lcrypt -lutil -lpthread -lc -L/usr/lib/python2.7/config -lpython2.7 -lpthread -ldl -lutil -lm -Xlinker -export-dynami
c   -lruby -lpthread -lgmp -ldl -lcrypt -lm  -L/usr/lib

ls -la .vim文件夹

drwxr-xr-x  4 trevor users 4.0K Mar 26 12:37 ./
drwx------ 29 trevor users 4.0K Mar 26 12:56 ../
drwxr-xr-x  4 trevor users 4.0K Mar 26 12:36 bundle/
drwxr-xr-x  2 trevor users 4.0K Mar 26 12:47 UltiSnips/

提前感谢您的帮助!我一直在试图弄清楚我的头发是什么问题。

3 个答案:

答案 0 :(得分:8)

我明白了。因此,对于当前版本,没有默认的片段,甚至没有剪切<tab>。一旦我添加了这个:Bundle 'honza/vim-snippets'一切都开始有效了。

答案 1 :(得分:2)

在我的案例中,UltiSnips并没有扩展,因为我的.vimrc中有set paste。打开该设置会禁用插入模式下的键映射。尝试删除该设置。它对我有用。

答案 2 :(得分:2)

在我的情况下,新定义的自定义代码段没有扩展。

根据帮助文件,我已经定义了一个我的代码片段所在的目录:

let g:UltiSnipsSnippetsDir="/Users/tony/ultisnips"

:UltiSnipsEdit!在要编辑的可选片段文件列表中显示此目录。所以我认为一切都应该有效。我可以通过:UltiSnipsEdit添加片段到我的自定义文件就好了。但是,显然,这并不足以让UltiSnips在扩展时找到其中的文件。

我将相同的目录添加到要搜索的目录列表后,我的代码段才被展开:

let g:UltiSnipsSnippetDirectories=["/Users/tony/ultisnips", "UltiSnips"]