7dn6ia
Last Updated: February 25, 2016
·
2.889K
· spf13
7bda40f7cf9bf734bb62fc7b5c752ce3

Best way to leave insert mode

vim

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.

Say Thanks
Respond

10 Responses
Add your response

140
Img 462742303

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 ·
1280
F17e757902ab6a18cba1bacaa976eb0f

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 ·
1295
Kevin suttle

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 ·
3380
8e996752beb62511466e10e6309c3204

@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 ·
3381
8e996752beb62511466e10e6309c3204

@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 ·
4091
Avatar

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

over 1 year ago ·
5469
Gravatar

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 ·
5916
06237052745686cba3fcb34d056d3cad

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

over 1 year ago ·
6192

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 ·
6437
Me

@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 ·