David542
David542

Reputation: 110432

Key mapping with chained keypresses

I normally use the ctrl-a and ctrl-e to go to the start and end of a line in vim. For example:

:inoremap <C-a> <Esc>0i
:inoremap <C-e> <Esc>$li

However, I would like to make go to the first word, which would be:

:inoremap <C-a><C-l> <Esc>^i

However, it does seem to register the second keypress. Is there a way to make sure that chained keypresses are always picked up that way, or how is this normally done?

Upvotes: 0

Views: 58

Answers (1)

romainl
romainl

Reputation: 196789

:inoremap <C-a> <Esc>0i
:inoremap <C-e> <Esc>$li

could be improved by avoiding the unnecessary mode switching (and weird $li):

:inoremap <C-a> <Home>
:inoremap <C-e> <End>

For jumping to the first printable character of the line, you could do:

:inoremap <C-a><C-l> <Home><S-Right>

Upvotes: 1

Related Questions