Fengyang Wang
Fengyang Wang

Reputation: 12051

Disable Return after i in vim

I have a bad habit of pressing the Return immediately after pressing the i key, when the o key would save keystrokes. I would like to disable the i-Return combination to help me break this habit.

I tried to add

imap <Return> <NOP>

to my ~/.config/nvim/init.vim, but this disables pressing it in insert mode entirely. Is there a way to disable it only upon immediately entering insert mode?

Upvotes: 0

Views: 78

Answers (1)

Ingo Karkat
Ingo Karkat

Reputation: 172590

How about this combo:

nnoremap <silent> i<CR> :echoerr "Use o instead"<CR>

This will issue the error only if you press both i and <Enter> within 'timeoutline' (default one second).

Upvotes: 3

Related Questions