简体   繁体   English

无法在.vimrc中重新映射%到%v,但可以在vim内

[英]Cannot remap % to %v in .vimrc but can inside vim

I want to remap % to v% to select the text inside matching braces (brackets, etc ) but I can only do it inside vim not in .vimrc . 我想重新映射%v%以选择匹配大括号(括号等)内的文本,但我只能在vim内部而不是.vimrc

I can do it like this in vim: 我可以在vim中这样做:

noremap % v%

or 要么

nnoremap % v%

(I don't really know the difference but the aim is to change the mapping only in normal mode) (我真的不知道区别,但目的是仅在正常模式下更改映射)

but when I do this in .vimrc I don't get the desired effect 但是当我在.vimrc这样做时,我没有达到预期的效果

my :noremap 我的:noremap

   î           *@:call AutoPairsJump()<CR>
   ð           *@:call AutoPairsToggle()<CR>
n  <C-L>       * :nohlsearch<CR><C-L>
o  %           * v:<C-U>call <SNR>15_Match_wrapper('',1,'o') <CR>
v  %           * :<C-U>call <SNR>15_Match_wrapper('',1,'v') <CR>m'gv``
n  %           * :<C-U>call <SNR>15_Match_wrapper('',1,'n') <CR>
   Q             <Nop>
n  R           * R<C-R>=<SNR>19_feedPopup()<CR>
x  S             <Plug>VSurround
o  [%          * v:<C-U>call <SNR>15_MultiMatch("bW", "o") <CR>
v  [%            <Esc>[%m'gv``
n  [%          * :<C-U>call <SNR>15_MultiMatch("bW", "n") <CR>
o  ]%          * v:<C-U>call <SNR>15_MultiMatch("W",  "o") <CR>
v  ]%            <Esc>]%m'gv``
n  ]%          * :<C-U>call <SNR>15_MultiMatch("W",  "n") <CR>
n  a           * a<C-R>=<SNR>19_feedPopup()<CR>
v  a%            <Esc>[%v]%
n  cs            <Plug>Csurround
n  ds            <Plug>Dsurround
n  gx            <Plug>NetrwBrowseX
x  gS            <Plug>VgSurround
o  g%          * v:<C-U>call <SNR>15_Match_wrapper('',0,'o') <CR>
v  g%          * :<C-U>call <SNR>15_Match_wrapper('',0,'v') <CR>m'gv``
n  g%          * :<C-U>call <SNR>15_Match_wrapper('',0,'n') <CR>
n  i           * i<C-R>=<SNR>19_feedPopup()<CR>
n  ySS           <Plug>YSsurround
n  ySs           <Plug>YSsurround
n  yss           <Plug>Yssurround
n  yS            <Plug>YSurround
n  ys            <Plug>Ysurround
n  <Plug>NetrwBrowseX * :call netrw#NetrwBrowseX(expand("<cWORD>"),0)<CR>
v  <Plug>VgSurround * :<C-U>call <SNR>16_opfunc(visualmode(),visualmode() ==# 'V' ? 0 : 1)<CR>
v  <Plug>VSurround * :<C-U>call <SNR>16_opfunc(visualmode(),visualmode() ==# 'V' ? 1 : 0)<CR>
n  <Plug>YSurround * :<C-U>set opfunc=<SNR>16_opfunc2<CR>g@
n  <Plug>Ysurround * :<C-U>set opfunc=<SNR>16_opfunc<CR>g@
n  <Plug>YSsurround * :<C-U>call <SNR>16_opfunc2(v:count1)<CR>
n  <Plug>Yssurround * :<C-U>call <SNR>16_opfunc(v:count1)<CR>
n  <Plug>Csurround * :<C-U>call <SNR>16_changesurround()<CR>
n  <Plug>Dsurround * :<C-U>call <SNR>16_dosurround(<SNR>16_inputtarget())<CR>
n  <Plug>SurroundRepeat * .

my .vimrc http://pastebin.com/qhUYzS9W 我的.vimrc http://pastebin.com/qhUYzS9W

This line gives it away: 这条线给了它:

n  %           * :<C-U>call <SNR>15_Match_wrapper('',1,'n') <CR>

The matchit.vim plugin overrides your mapping. matchit.vim插件会覆盖您的映射。 ( :verbose nmap % would have told you, too). :verbose nmap %也会告诉你)。

As the plugin doesn't provide alternative <Plug> mappings, it's an either-or: Keep your mapping (and remove the plugin script and it extended matching), or choose another key for your mapping. 由于插件不提供替代的<Plug>映射,它是 - 或者:保持映射(并删除插件脚本并扩展匹配),或者为映射选择另一个键。

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

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