简体   繁体   中英

Vim's (MVIM) Local Leader, BackSlash Only Beeps

I'm new to VIM, using MacVim, and I'm trying to use Backslash as local leader. It seems like that is the default. If I do:

:let maplocalleader = "\\"

I just get a beep when I try to use local leader key \\

If I do

:let maplocalleader = "-"

Then it works just fine. How do I get vim to stop beeping at me every time I try to use the backslash key?

\\\\\\ is definitely wrong way to escape backslash. Inside double quotes it should be written as "\\\\" , inside single as '\\' . "\\\\\\" is an unfinished string '\\"' (third backslash escapes double quote) thus it will show error after :let command.

The beep source is different: \\ key on its own is no-op unlike - . If you have mapping to -a and type just - then cursor will move to the previous line: it is a valid action. If you have mapping \\a (or no mappings at all) and type \\ you will see beep because \\ is not a valid action. Only mappings like \\a are valid thus they won't beep.

You need to put that command in your vimrc. Leader and local leader commands to not affect commands that have already been parsed by vim.

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