使用VIM,同时使用snipMate和pydiction(共享<tab>键?)

tho*_*mad 16 vim autocomplete code-snippets

我试图在vim中使用snipMatepydiction - 但是,两者都使用<tab>密钥来执行他们的天才 - 自动完成 - 片段渲染 - 良好 - 我渴望.

安装pydiction时,snipMate停止工作.我认为它是因为他们不能拥有<tab>密钥.我怎样才能让他们一起工作?

我不介意将其中一个映射到一个不同的键,但我不确定如何做到这一点...(可能是对<ctrl-n>键的嘲讽所以它模仿vim的自动完成?).

这是相关的.vimrc:

filetype indent plugin on 

autocmd FileType python set ft=python.django 
autocmd FileType html set ft=html.django_template 

let g:pydiction_location = '~/.vim/ftplugin/pydiction-1.2/complete-dict'
Run Code Online (Sandbox Code Playgroud)

the*_*rel 15

好吧,这是来自Snipmate帮助文件:)

                                                              *snipMate-remap*
snipMate does not come with a setting to customize the trigger key, but you
can remap it easily in the two lines it's defined in the 'after' directory
under 'plugin/snipMate.vim'. For instance, to change the trigger key
to CTRL-J, just change this: >

 ino <tab> <c-r>=TriggerSnippet()<cr>
 snor <tab> <esc>i<right><c-r>=TriggerSnippet()<cr>

to this: >
 ino <c-j> <c-r>=TriggerSnippet()<cr>
 snor <c-j> <esc>i<right><c-r>=TriggerSnippet()<cr>
Run Code Online (Sandbox Code Playgroud)

  • 不再是真的,现在文档指定可以使用`imap <CJ> <Plug> snipMateNextOrTrigger`和`smap <CJ> <Plug> snipMateNextOrTrigger重新映射它. (3认同)

小智 7

或者,您可以编辑~/.vim/after/ftplugin/python_pydiction.vim 并更改Tab为其他内容:

" Make the Tab key do python code completion:
inoremap <silent> <buffer> <Tab> 
         \<C-R>=<SID>SetVals()<CR>
         \<C-R>=<SID>TabComplete('down')<CR>
         \<C-R>=<SID>RestoreVals()<CR>

" Make Shift+Tab do python code completion in the reverse direction:
inoremap <silent> <buffer> <S-Tab> 
         \<C-R>=<SID>SetVals()<CR>
         \<C-R>=<SID>TabComplete('up')<CR>
         \<C-R>=<SID>RestoreVals()<CR>
Run Code Online (Sandbox Code Playgroud)