pksimba
pksimba

Reputation: 193

vim nmap which disables another nmap

In my .vimrc I have these lines

nmap :s :update<cr>
nmap <F5> :set number!<cr>

Without the former mapping, the latter works, otherwise it doesn't. Why is this the case?

Upvotes: 3

Views: 108

Answers (1)

Enlico
Enlico

Reputation: 28406

The problem is that the second mapping begins in a way, :s in :set, that triggers the previous mapping.

In general you should use non-recursive mappings, unless you have a reason to use recursive mappings.

In this case, you have to use

nnoremap :s :update<cr>
nnoremap <F5> :set number!<cr>

More info at

Upvotes: 5

Related Questions