th1rdey3
th1rdey3

Reputation: 4358

How to insert/type key sequences that are mapped with imap

I have just started using VIM. The one thing that stains me most while using VIM is the Esc key. So after some googling I found this link: Avoid the escape key and used it to map jk to Esc. I put this command in _vimrc file:

imap jk <Esc>

It's working fine. But now my question is if I need to type jk in vim, how should I do it. One way is to type something like jik then remove the i. But is there any better way of doing it?

Upvotes: 0

Views: 101

Answers (3)

Arjen Dijkstra
Arjen Dijkstra

Reputation: 1549

You can type Ctrl[. For me this is easier than reaching for the escape key. See:

:h i_CTRL-[

Upvotes: 1

Ingo Karkat
Ingo Karkat

Reputation: 172580

If you don't want to wait for the timeout, an alternative is pressing Ctrl + V somewhere, i.e. either <C-V>jk or j<C-V>k. This key combination means "insert next char literally". (On Windows, you often need to use <C-Q> instead.)

Upvotes: 1

Amadan
Amadan

Reputation: 198324

  • Wait more than timeoutlen milliseconds (:help timeoutlen, :set timeoutlen?)
  • Do something else in the meantime (as you suggest)
  • Don't map key sequences that you're likely to type

jk is a common choice because no English words contain it. If your language does, don't use it, or change it to something you are not likely to bump into.

Upvotes: 1

Related Questions