vimium-c icon indicating copy to clipboard operation
vimium-c copied to clipboard

How to map jj/jk as escape key when in insert mode?

Open uzza1hossain opened this issue 2 years ago • 1 comments

I tried multiple formats none of them worked. mapKey mapKey "jj" mapKey jj

uzza1hossain avatar Sep 09 '22 14:09 uzza1hossain

No you can't. Vimium C's InsertMode can only exit on a single key.

If you mean a plain insert mode auto entered when an input box is focused, then mapKey <any_key> <esc> will make Vimium C exit insert mode on the key.

If you mean the command named enterInsertMode, then it support a parameter of key to exit on a "neither-letter-nor-number" key, like <c-a> or <f1>:

map i enterInsertMode key="<c-i>"

gdh1995 avatar Sep 10 '22 12:09 gdh1995

If you mean a plain insert mode auto entered when an input box is focused, then mapKey <any_key> <esc> will make Vimium C exit insert mode on the key.

is it possible to bind several keys/combos to exit insert mode for the mapping ?

elig0n avatar Oct 19 '22 16:10 elig0n

No. enterInsertMode's key can only be one (composed) key. But there're some other commands to simulate it.

  1. the below code means c and a following d will make Vimium C exit from disabled mode
map i openUrl url="vimium://status/disable/^%20c"
mapKey c <v-c>
mapKey <c:i> <v-c> # work around an issue in v1.99.3 that `mapKey c <v-c>` doesn't work in insert mode
map <v-c>d openUrl url="vimium://status/reset"
  • you may replace d with other sequences of keys.
  • <v-c> is just a inner name and can be renamed into anything looking like <v-***>
  • c is only an example, and it will prevent you from typing c characters in an input box; so a better "first key" can be a composed key (like <a-a>) or F1-F12 .

gdh1995 avatar Oct 20 '22 04:10 gdh1995

If you want to trigger key sequences in a "plain" insert mode (not from enterInsertMode, but entered when an input box is focused), then this is just enough:

mapKey <c:i> <v-c>
map <v-c>d dispatchEvent esc

gdh1995 avatar Oct 20 '22 04:10 gdh1995