Vimium: Allow any key to mapped to "exit mode" instead of just <esc>

Created on 18 Feb 2011  路  21Comments  路  Source: philc/vimium

I have jj remapped to in vim since its easier to type. Would it be possible to make a remapping such as this work to leave insert mode?

Thanks

help-wanted verified

Most helpful comment

Reopening and removing _wont-fix_ label.

This is indeed a feature that is requested _a lot_. It was closed as part of a cull of long-standing open issues.

All 21 comments

Yeah, we should have a command equivalent to escape - that would be useful.

Agreed.

You can also use <C-[> in vim; it's supported out of the box and in fact is considered to be the same key as <ESC>. Maybe we could add that instead of introducing another command mapping.

I'd also find this feature to be useful. I've read that the ESC key on keyboards when vi was first written was closer to where the q is now instead of up in the corner. This makes sense, since reaching all the way up to the corner so frequently is not all that convenient.

Any news on this issue? Is it too difficult to implement? For me it's an inconsistency between vim and vimium since vim is mapped to jj for me as well.

It's not too difficult. It's a great starter bug if someone would like to try their hand at this enhancement.

Do we want to implement this only for normal mode, or for all modes (like input and find)? If it's the latter, it's not going to be that simple.

To be consistent any remap of should apply to all modes. Why would it be particularly difficult, apart from ensuring the code paths for each mode reference the same "exitKey" var?

Right now the code that allows configurable matching of keys to commands lives in the background page, and only handles normal-mode keypresses. Remapping keys is essentially done by changing our key-to-command 'routing table'. On the other hand, quitting in find or insert modes relies on a special-case code path in the content script (KeyboardUtils.isEscape) that explicitly checks if the keypress event is what we would consider an 'escape' event, and the keypress never reaches the background page. To implement this bug, we could either a) have the background page inform the content scripts what an 'escape' event should look like in advance, or b) have the background page record keypresses even in find and insert modes, but to do nothing unless it is an 'escape' event, in which case it tells the content scripts to quit whichever mode is currently active.

I'm in favor of the latter as I think it is more elegant to use the same configurable key mapping logic for all modes. Moreover, this opens up the possibility for emulating Vim's nmap and imap commands, whereby the user can define mappings that are only active in the normal or insert modes respectively.

Good stuff. Thanks for the writeup. Maybe this isn't low-hanging-fruit for a first-timer =)

I don't have a strong preference, but the first proposal does sound easier to implement.

I would to see this in addition to Vim's nmap and imap commands,

I have tried to implement this in PR #1140. Due to the nature of input mode, it only accepts single keys bound to exitInsertMode.

+1

+1

馃憥

Hi @smblott-github, just curious why this was labeled won't-fix? I started using insert mode more frequently with Vimium (rather than disabling the plugin for certain pages), but it would be nice if people could exit using their preferred binding, in my case <C-c>.

Reopening and removing _wont-fix_ label.

This is indeed a feature that is requested _a lot_. It was closed as part of a cull of long-standing open issues.

Folks, see #2253.

Thanks a lot, your efforts are appreciated!

Folks, see here. PR #2253 has hit a little bit of a road bump. Input would be appreciated.

Closing, see this comment.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

umutyazgan picture umutyazgan  路  4Comments

Semro picture Semro  路  3Comments

everyonesdesign picture everyonesdesign  路  3Comments

nick-s-b picture nick-s-b  路  4Comments

jkbbwr picture jkbbwr  路  3Comments