我想将 control+space 映射到 :bnext 以便在正常模式下转发切换。所以我在我的 .vimrc 中添加了以下内容:
nnoremap <silent> <C-Space> :bn<CR>
对于后向搜索
nnoremap <silent> <C-S-Space> :bp<CR>
但是,此解决方案不起作用。关于问题是什么以及如何解决它的任何想法?
更新:我的映射列表:
n [m *@:call <SNR>45_Python_jump('?^\s*\(class\|def\)')<CR>
n [[ *@:call <SNR>45_Python_jump('?^\(class\|def\)')<CR>
n ]m *@:call <SNR>45_Python_jump('/^\s*\(class\|def\)')<CR>
n ]] *@:call <SNR>45_Python_jump('/^\(class\|def\)')<CR>
<F7> *@:call Flake8()<CR>
n <Tab> * <C-W>w
n <CR> * :call gruvbox#hls_hide()<CR><CR>
n * * :let @/ = ""<CR>:call gruvbox#hls_show()<CR>*
n ,tj :call Tj()<CR>
n ,st :call Sts()<CR> <Space>
n / * :let @/ = ""<CR>:call gruvbox#hls_show()<CR>/
n ? * :let @/ = ""<CR>:call gruvbox#hls_show()<CR>?
n \ca <Plug>NERDCommenterAltDelims
x \cu <Plug>NERDCommenterUncomment
n \cu <Plug>NERDCommenterUncomment
x \cb <Plug>NERDCommenterAlignBoth
n \cb <Plug>NERDCommenterAlignBoth
x \cl <Plug>NERDCommenterAlignLeft
n \cl <Plug>NERDCommenterAlignLeft
n \cA <Plug>NERDCommenterAppend
x \cy <Plug>NERDCommenterYank
n \cy <Plug>NERDCommenterYank
x \cs <Plug>NERDCommenterSexy
n \cs <Plug>NERDCommenterSexy
x \ci <Plug>NERDCommenterInvert
n \ci <Plug>NERDCommenterInvert
n \c$ <Plug>NERDCommenterToEOL
x \cn <Plug>NERDCommenterNested
n \cn <Plug>NERDCommenterNested
x \cm <Plug>NERDCommenterMinimal
n \cm <Plug>NERDCommenterMinimal
x \c<Space> <Plug>NERDCommenterToggle
n \c<Space> <Plug>NERDCommenterToggle
x \cc <Plug>NERDCommenterComment
n \cc <Plug>NERDCommenterComment
n \b * :CommandTBuffer<CR>
n \t * :CommandT<CR>
v \<Space> * <Esc>:call gruvbox#hls_toggle()<CR>gv
n \<Space> * :call gruvbox#hls_toggle()<CR>
n gx <Plug>NetrwBrowseX
n <Plug>NetrwBrowseX * :call netrw#NetrwBrowseX(expand("<cWORD>"),0)<CR>
n <Plug>NERDCommenterAltDelims * :call <SNR>17_SwitchToAlternativeDelimiters(1)<CR>
x <Plug>NERDCommenterUncomment * :call NERDComment("x", "Uncomment")<CR>
n <Plug>NERDCommenterUncomment * :call NERDComment("n", "Uncomment")<CR>
x <Plug>NERDCommenterAlignBoth * :call NERDComment("x", "AlignBoth")<CR>
n <Plug>NERDCommenterAlignBoth * :call NERDComment("n", "AlignBoth")<CR>
x <Plug>NERDCommenterAlignLeft * :call NERDComment("x", "AlignLeft")<CR>
n <Plug>NERDCommenterAlignLeft * :call NERDComment("n", "AlignLeft")<CR>
n <Plug>NERDCommenterAppend * :call NERDComment("n", "Append")<CR>
x <Plug>NERDCommenterYank * :call NERDComment("x", "Yank")<CR>
n <Plug>NERDCommenterYank * :call NERDComment("n", "Yank")<CR>
x <Plug>NERDCommenterSexy * :call NERDComment("x", "Sexy")<CR>
n <Plug>NERDCommenterSexy * :call NERDComment("n", "Sexy")<CR>
x <Plug>NERDCommenterInvert * :call NERDComment("x", "Invert")<CR>
n <Plug>NERDCommenterInvert * :call NERDComment("n", "Invert")<CR>
n <Plug>NERDCommenterToEOL * :call NERDComment("n", "ToEOL")<CR>
x <Plug>NERDCommenterNested * :call NERDComment("x", "Nested")<CR>
n <Plug>NERDCommenterNested * :call NERDComment("n", "Nested")<CR>
x <Plug>NERDCommenterMinimal * :call NERDComment("x", "Minimal")<CR>
n <Plug>NERDCommenterMinimal * :call NERDComment("n", "Minimal")<CR>
x <Plug>NERDCommenterToggle * :call NERDComment("x", "Toggle")<CR>
n <Plug>NERDCommenterToggle * :call NERDComment("n", "Toggle")<CR>
x <Plug>NERDCommenterComment * :call NERDComment("x", "Comment")<CR>
n <Plug>NERDCommenterComment * :call NERDComment("n", "Comment")<CR>
<F4> :Tlist<CR>
n <C-Space> * :bnext<CR>
n <S-Tab> * <C-W>W
<F3> :NERDTreeToggle<CR><CR>
我尝试时的缓冲区:
:ls
1 # "views.py" line 73
2 %a "./forms.py" line 19
什么原因导致问题?你能帮我吗?
最佳答案
在大多数终端中(我假设您正在使用,因为您没有指定 gVim/MacVim),<C-Space>
和 <C-S-Space>
不要映射到实际的 ASCII 字符。您可以通过进入插入模式来确认这一点,输入 <C-V>
启动文字字符插入,然后键入其中任何一个键。如果您看到 ^@
这意味着您输入了无法映射到的 Null 字符。所以不幸的是,你要么需要切换到 Vim 的 GUI 风格(它确实理解非 ASCII 映射),要么选择不同的映射。
编辑:我的错误,可以通过 <NUL>
映射空字符,正如另一个答案指出的那样。还是没有区别<C-S-Space>
和 <C-Space>
(或 <C-j>
和 <C-@>
),但您至少可以映射它们。
关于vim - 普通模式下Control+空格vim键绑定(bind)不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23189568/