Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
    
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. –  movingtype 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

2 Answers 2

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>
share|improve this answer
    
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. –  movingtype Jul 10 '13 at 2:03
up vote 0 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.