I know the 'z' key has some kind of special function in Vim, it activates many double key shortcuts (so does 'g'), but almost all of them are assigned to folding, something that I never use. So I really would like 'z' to be my leader key.

But that is not working. Suppose I want 'zw' as a shortcut for 'writing' the buffer:

nnoremap <Leader>w ^[:w<CR>

That causes an error claiming that "Spell checking is not enabled."

The default binding for 'zw' is 'mark word as wrong,' so obviously my configuration change is not working.

What do I have to do to be able to use z as the leader key?

  • Do you have those &lt; in your ~/.vimrc? – romainl Jul 10 '13 at 7:07
  • No. Those are angle brackets. This site wouldn't let me enter them, they were disappearing as if they were HTML markup. Now I changed them and they work. Weird. – user223557 Jul 10 '13 at 15:48
  • that's because you need to put 4 spaces before your code snippets to make them actual code snippets. – romainl Jul 10 '13 at 19:31

Leader key is not same as ':' what is a switch to 'command-mode'. Leader key is described here correctly.

If you want to change leader key (default it is \), then you have to set it with

let mapleader = 'z'

and zw will work as you expect. However, I recommend to not choose this way.

Vim already has a handy shortcut to save a file and quit: ZZ (hold shift and press 'z' twice). If you want to only save a file and not quit, I recommend to map it to ZX with

nmap ZZ <ESC>:w<CR>
  • let mapleader = 'z' Yes, I already have that in my .vimrc. I forgot to mention it. I am not doing this just for ZZ, I picked w/write as an example, I actually want to map z{something} to a bunch of macros that are a lot more useful to me than folding. – user223557 Jul 10 '13 at 2:03

I found the answer myself.

Everything I had been doing was right, except I had this line in my .vimrc:

set timeoutlen=100

That was killing the 'z' leader. Everything works fine without that line.

This is embarrassing. Sorry.

  • It's in milliseconds so I set it at 4000 = 4seconds c: Also to see where you are in the command you are typing, you can add set showcmd in your vimrc – Boop Feb 18 '17 at 16:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy