简体   繁体   English

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

[英]With VIM, use both snipMate and pydiction together (share the <tab> key?)

I am trying to use snipMate and pydiction in vim together - however, both use the <tab> key to perform their genius-auto-completion-snippet-rendering-goodness-that-I-so-desire. 我试图在vim中使用snipMatepydiction - 但是,两者都使用<tab>键来执行他们的genius-auto-completion-snippet-rendering-goodness-that-I-so-desire。

When pydiction is installed, snipMate stops working. 安装pydiction时,snipMate停止工作。 I assume its because they can't both own the <tab> key. 我认为它是因为他们不能拥有<tab>键。 How can I get them to work together? 我怎样才能让他们一起工作?

I wouldn't mind mapping one of them to a different key, but I am not really sure how to do this ... (maybe pydiction to the <ctrl-n> key so it mimics vim's autocomplete?). 我不介意将其中一个映射到一个不同的键,但我不确定如何做到这一点...(可能是对<ctrl-n>键的假设,所以它模仿vim的自动完成?)。

Here is the relevant .vimrc: 这是相关的.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'

Well, this is from the Snipmate help file :) 好吧,这是来自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>

Alternatively, you can edit ~/.vim/after/ftplugin/python_pydiction.vim and change Tab to something else: 或者,您可以编辑~/.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>

I believe the way to change the trigger key may have changed since the answer by the_karel was given in 2009 but it is found in the same directory, namely 'after/plugin/snipMate.vim'. 我相信更改触发器键的方式可能已经改变,因为the_karel的答案是在2009年给出的,但它位于同一目录中,即'after / plugin / snipMate.vim'。 I found it in the help file too: 我也在帮助文件中找到了它:

 *snipMate-trigger*
snipMate comes with a setting to configure the key that is used to trigger
snipMate. To configure the key set g:snips_trigger_key to something other than
<tab>,e.g. <c-space> use:

 let g:snips_trigger_key='<c-space>'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM