简体   繁体   中英

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 .

I can do it like this in 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

my :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

This line gives it away:

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

The matchit.vim plugin overrides your mapping. ( :verbose nmap % would have told you, too).

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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