I'm trying to change <Leader>
in MacVim to be something less carpal-tunnel inducing. I have added this line
let mapleader=","
to my .gvimrc, but "\" is still the only key that works. Am I missing something?
The leader key provides a facility for creating customized shortcuts that can be further restricted to apply only in certain modes, such as normal, insert, visual, terminal (neovim-specific), etc. The leader key is normally defined by the mapleader variable as \ .
To map a sequence of keys to execute another sequence of keys, use the ':map' command. For example, the following command maps the <F2> key to display the current date and time. The ':map' command creates a key map that works in normal, visual, select and operator pending modes.
Vim has a second "leader" key called "local leader". This is meant to be a prefix for mappings that only take effect for certain types of files, like Python files or HTML files. Notice that we have to use \\ and not just \ because \ is the escape character in Vimscript strings.
<silent> tells vim to show no message when this key sequence is used. <leader> means the key sequence starts with the character assigned to variable mapleader -- a backslash, if no let mapleader = statement has executed yet at the point nmap executes.
The line needs to go into your normal .vimrc
(instead of .gvimrc
). .gvimrc
is not read until all plugins have been loaded, by which time all the mappings have already been created with the default map leader.
.gvimrc
is intended only for GUI-specific options, everything else should be in .vimrc
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With