Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow any key to mapped to "exit mode" instead of just <esc> #301

Closed
sture opened this issue Feb 18, 2011 · 21 comments
Closed

Allow any key to mapped to "exit mode" instead of just <esc> #301

sture opened this issue Feb 18, 2011 · 21 comments

Comments

@sture
Copy link

sture commented Feb 18, 2011

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

@ilya
Copy link
Collaborator

ilya commented Feb 18, 2011

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

@philc
Copy link
Owner

philc commented Feb 18, 2011

Agreed.

@changemewtf
Copy link
Contributor

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.

@arbrown
Copy link

arbrown commented Jul 1, 2011

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.

@joshvoigts
Copy link

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.

@philc
Copy link
Owner

philc commented Jul 13, 2012

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

@int3
Copy link
Collaborator

int3 commented Sep 3, 2012

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.

@philc
Copy link
Owner

philc commented Sep 3, 2012

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?

@int3
Copy link
Collaborator

int3 commented Sep 4, 2012

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.

@philc
Copy link
Owner

philc commented Sep 6, 2012

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.

@y2kbugger
Copy link

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

@mrmr1993
Copy link
Contributor

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

@tecfu
Copy link

tecfu commented Mar 29, 2015

+1

@ewilazarus
Copy link

+1

@y2kbugger
Copy link

👎

@danijar
Copy link

danijar commented Sep 13, 2016

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>.

@smblott-github
Copy link
Collaborator

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.

@smblott-github
Copy link
Collaborator

Folks, see #2253.

@danijar
Copy link

danijar commented Sep 17, 2016

Thanks a lot, your efforts are appreciated!

@smblott-github
Copy link
Collaborator

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

@smblott-github
Copy link
Collaborator

Closing, see this comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment