[英]Can I use SPACE as mapleader in VIM?
From http://items.sjbach.com/319/configuring-vim-right (2009 archive from original) I got that you were supposed to be able to use Space as the mapleader
in vim.从http://items.sjbach.com/319/configuring-vim-right(2009 年原始档案)我知道你应该能够在 vim 中使用Space作为mapleader
。 I've tried but it does not seem to work.我试过了,但似乎没有用。 Is there anyone who made it work?有没有人让它发挥作用?
Tried:试过:
let mapleader = <space>
Try the following instead:请尝试以下操作:
let mapleader=" "
And remember to write the following line before that, to make sure spacebar doesn't have any mapping beforehand:并记住在此之前写下以下行,以确保空格键事先没有任何映射:
nnoremap <SPACE> <Nop>
Mapleader is a Vim string variable. Mapleader 是一个 Vim 字符串变量。 To use space as leader, you must escape the special character.要使用空格作为前导符,您必须转义特殊字符。
let mapleader="\<Space>"
For more info see,有关更多信息,请参阅
http://vimdoc.sourceforge.net/htmldoc/eval.html#expr-quote http://vimdoc.sourceforge.net/htmldoc/eval.html#expr-quote
EDIT:编辑:
This no longer works for me in my version of Vim.这在我的 Vim 版本中不再适用于我。 Even with the suggestion in the comments of unmapping the spacebar in normal mode by running nnoremap <SPACE> <Nop>
.即使在注释中建议通过运行nnoremap <SPACE> <Nop>
在正常模式下nnoremap <SPACE> <Nop>
空格键。
I ending up going with the solution given in the answer below.我最终采用了下面答案中给出的解决方案。
map <Space> <Leader>
The above solutions are great, however, nothing shows up in the bottom right command corner.上面的解决方案很棒,但是,右下角的命令角没有显示任何内容。 If you don't have any use for the \\
key anyway, try using map <SPACE> <leader>
and \\
will show up in the command corner.如果您无论如何都没有使用\\
键,请尝试使用map <SPACE> <leader>
并且\\
将显示在命令角中。 That and you don't have to unmap space first, as suggested in the commends above.那你不必先取消映射空间,正如上面的推荐中所建议的那样。
nnoremap <space> <Nop> nnoremap <space> <Nop>
nnoremap <nowait> <space> / nnoremap <nowait> <space> /
If you are using neovim and lua config, you can try it:如果你使用的是 neovim 和 lua config,你可以试试:
-- map leader to <Space>
vim.keymap.set("n", " ", "<Nop>", { silent = true, remap = false })
vim.g.mapleader = " "
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.