Last Updated: September 09, 2019
·
3.856K
· spf13

Best way to leave insert mode

No configuration needed. While all the other newbies are leaving the home row to hit escape (or remapping caps lock) you'll be flying with typing 'ctrl + c' instead.

10 Responses
Add your response

If you don't want Vim to check for abbreviatons or autocommand events, though. Ctrl-[, on the other hand, behaves just like the escape key.

over 1 year ago ·

If you don't care about your caps lock key, just remap that key to escape and that's a one key leaving insert mode tip:)

over 1 year ago ·

It seems to be a convention to leave Insert mode by remapping 'jj' to ESC. Works for me quite well. https://github.com/kevinSuttle/dotfiles/blob/master/vim/.vimrc#L24

over 1 year ago ·

@yannick Caps lock is better as additional Ctrl, not only for emacs guys, but for vimers too. In most keyboards - left Ctrl is really hard to reach.

over 1 year ago ·

@kevinsuttle "jk" is really faster. "jj" you must type with one finger, but "jk" you can press with two fingers practically simultaneously

over 1 year ago ·

Typing Ctrl+C just inserts # in my line while in insert mode O.o

over 1 year ago ·

I prefer ",,". I found out that, very rarely, I need to actually type "jj" or "jk" without leaving insert mode. Never happened with two commas (unless CSV)

over 1 year ago ·

There is no best way. Mapping ESC to Capslock globally benefits me in a lot of ways :)

over 1 year ago ·

Handy, but these two are not synonymous. For instance InsertLeave event doesn't fire while using Ctrl + c.

http://rsontech.net/2012/05/13/ctrl-c-is-not-escape.html has some details on the differences

over 1 year ago ·

@aeonbeat this or voice enabled vim is definitely the best.

@spf13
Ctrl-c is like cross breeding emacs with vim. It is not a good idea for a frequently used command. Ergonomically, all keys lower than the home row keys are more likely to cause RSI related injuries. This use case is definitively more harmful when using the left hand only ctrl+z,x,c,v commands frequently.

If somebody really truly wants to improve their speed and ergonomics of their development process, learn colemak. It took me no longer than 2 weeks to learn the new mapping in muscle memory, and its designed so that switching between qwerty and colemak is simple. For example I'm using qwerty to type this on android and colemak to code on my laptop.

Its one of the beat decisions I've ever made optimizing my development process considering I have a bad habit of programming for long periods of time. Any hacker who doesn't adopt colemak is just doing it wrong.

Edit: BTW this is the colemak vim key mapping I highly recommend that remaps hjkl into a two handed navigation.
http://www.ryanheise.com/colemak/

Its also more ergonomic because it reduces usage of right pinky. Which for programmers is used as/more frequently as the thumbs in most languages with C like syntax. Right pinky is responsible for brackets, braces, enter, backspace, semi/colon, plus, minus, equals, division, backslash, quotes, apostrophe, right shift. Having right cursor navigation added to the abuse is just not acceptable to anybody who passionately cares about being able to enjoy programming comfortably for long into the future.

over 1 year ago ·