如何为不同的 vim 插件设置不同的 <leader>
How to set distinct <leader> for a distinct vim plugin
我在插件 jedi-vim 的默认键映射和我自定义的键映射之间存在冲突。
" I mapped some cscope functions like below
nnoremap <leader>g :cscope find g <c-r>=expand('<cword>')<cr><cr>
nnoremap <leader>d :cscope find d <c-r>=expand('<cword>')<cr><cr>
但是,此键绑定被 g:jedi#goto_assignments_command
和 g:jedi#goto_command
jedi-vim.
的键绑定覆盖
我想知道是否可以只为 jedi-vim 设置一个不同的 <leader>
而不是重新映射冲突的键。
显然 jedi-vim 不使用规范的 <Plug>
-映射,而是使用单独的配置变量。尽管如此
let g:jedi#goto_assignments_command = ",g"
let g:jedi#goto_command = ",d"
在您的 ~/.vimrc
中(即在获取 jedi-vim 之前)应该可以解决问题,这就是我的建议。
备选
<Leader>
键受 mapleader
变量的影响。来自 :help <Leader>
:
Note that the value of "mapleader" is used at the moment the mapping is
defined. Changing "mapleader" after that has no effect for already defined
mappings.
所以,你也可以这样解决:
let mapleader = ','
runtime! plugin/jedi.vim
unlet mapleader
插件管理器或安装为 pack 插件 进一步复杂化,它改变了插件初始化的顺序。我不推荐这个。
关注@Ingo answer. I remaped most used functions in jedi-vim docu:
:let g:jedi#goto_command = ",jd"
:let g:jedi#goto_assignments_command = ",jg"
:let g:jedi#usages_command = ",jn"
:let g:jedi#rename_command = ",jr"
" will auto-create next visual-map: ,jr *@:call jedi#rename_visual()<CR>
" rename_command() fails in normal-mode, but success in visual-mode !
:let g:jedi#goto_stubs_command = ",js"
:let g:jedi#documentation_command = ",jK"
" s <C-Space> *@'<C-G>c'.jedi#complete_string(0)
:let g:jedi#completions_command = "<C-J>"
" jedi-vim Plug called AFTER remaping its commands only
Plug 'davidhalter/jedi-vim', {'for': 'python'}
PD:这应该是Karkat先生回答的评论,但仍然没有50分。
我在插件 jedi-vim 的默认键映射和我自定义的键映射之间存在冲突。
" I mapped some cscope functions like below
nnoremap <leader>g :cscope find g <c-r>=expand('<cword>')<cr><cr>
nnoremap <leader>d :cscope find d <c-r>=expand('<cword>')<cr><cr>
但是,此键绑定被 g:jedi#goto_assignments_command
和 g:jedi#goto_command
jedi-vim.
我想知道是否可以只为 jedi-vim 设置一个不同的 <leader>
而不是重新映射冲突的键。
显然 jedi-vim 不使用规范的 <Plug>
-映射,而是使用单独的配置变量。尽管如此
let g:jedi#goto_assignments_command = ",g"
let g:jedi#goto_command = ",d"
在您的 ~/.vimrc
中(即在获取 jedi-vim 之前)应该可以解决问题,这就是我的建议。
备选
<Leader>
键受 mapleader
变量的影响。来自 :help <Leader>
:
Note that the value of "mapleader" is used at the moment the mapping is defined. Changing "mapleader" after that has no effect for already defined mappings.
所以,你也可以这样解决:
let mapleader = ','
runtime! plugin/jedi.vim
unlet mapleader
插件管理器或安装为 pack 插件 进一步复杂化,它改变了插件初始化的顺序。我不推荐这个。
关注@Ingo answer. I remaped most used functions in jedi-vim docu:
:let g:jedi#goto_command = ",jd"
:let g:jedi#goto_assignments_command = ",jg"
:let g:jedi#usages_command = ",jn"
:let g:jedi#rename_command = ",jr"
" will auto-create next visual-map: ,jr *@:call jedi#rename_visual()<CR>
" rename_command() fails in normal-mode, but success in visual-mode !
:let g:jedi#goto_stubs_command = ",js"
:let g:jedi#documentation_command = ",jK"
" s <C-Space> *@'<C-G>c'.jedi#complete_string(0)
:let g:jedi#completions_command = "<C-J>"
" jedi-vim Plug called AFTER remaping its commands only
Plug 'davidhalter/jedi-vim', {'for': 'python'}
PD:这应该是Karkat先生回答的评论,但仍然没有50分。