5 ms·
Another important vim tip for me that wasn't in there and might be one for the author himself: you can use ctrl-C or ctrl-[ instead of ESC to exit insert mode.
by gfodor 16y ago
Another important vim tip for me that wasn't in there and might be one for the author himself: you can use ctrl-C or ctrl-[ instead of ESC to exit insert mode. This, combined with re-mapping capslock to control, is a big, big win.
- rue 16y agoI have mapped hh (jj on a QWERTY) to ESC.
- atuladhar 16y agoThank you!
- viraptor 16y agoYou can remap ESC to whatever you need. I prefer CTRL+s == ESC: inoremap <C-s> <ESC> vnoremap <C-s> <ESC>
- klochner 16y agoIt's also common to remap ii to exit insert mode, that way "i" puts you in, "ii" takes you out. Personally, I remapped caps lock to esc, because I don't like the way the editor lags when typing an "i" after "ii" has been remapped, but Caps-->Ctrl has the additional benefit of making other Ctrl-Foo sequences easy.
- pyre 16y ago> Personally, I remapped caps lock to esc, because I don't like the > way the editor lags when typing an "i" after "ii" That's the problem with mapping non-Ctrl/Alt sequences in Insert mode. Even thing like bindings that automatically insert a closing } (with auto-indent) when you type the opening { are really annoying because they are commonly bound to the sequence "{<Enter>". So when you type { without <Enter> there is a delay while it waits to see if you're going to hit <Enter>.
- stuhacking 16y agoHow would one insert the string 'ascii'?
- throw_away 16y agobut be sure to choose something you won't mind typing in regular non-vim contexts as well, as you'll eventually pick up a habit of hitting your <esc> equivalent pretty much whenever you stop to think. <ctrl-w> would be a horrible choice :)
- jjcm 16y agoI personally just remap capslock to ESC directly. I'm in vim a large majority of the time that I'm working, so it's a very big jump in productivity for me.
- chancho 16y agoCtrl-c and ctrl-[ are not the same. There are times when latter completes the insert session (same as esc) while the former aborts it, e.g. visual block insertion with (ctrl-v jjjj I) Also, the happy haacking keyboard already puts control in its proper place and puts esc where ~ normally is, which is close enough that you don't really need to remap it. Best vim keyboard ever.
- pyre 16y agoIt's more helpful to think of ctrl-[ as an analog to ESC (this also works in Emacs, irssi, etc as well IIRC). Ctrl-c just happens to work for exiting Insert mode because ctrl-c is the 'abort' command, and technically Insert mode is an operation. Insert mode is not Vim's 'normal' mode. When you enter Insert Mode, you are basically saying, "I'm stepping out of normal mode for a bit to enter some text here." In this sense, hitting ctrl-c is telling Vim that you're aborting your insert operation. (Though I could just be talking out of my ass, and it was just bound that way as a convenience)
- wyclif 16y agokeyboard already puts control in its proper place and puts esc where ~ normally is, which is close enough that you don't really need to remap it Unicomp makes a Model M that does this as well, very worthwhile if you are a vim or Emacs user: http://pckeyboards.stores.yahoo.net/linux101.html http://pckeyboards.stores.yahoo.net/linux101.html
- clvv 16y agoSome vim users also remap their caps lock to Esc (modify ~/.Xmodmap on linux, also doable on Windows and Mac), whereas Emacs users will probably remap their caps lock to Ctrl.
- jberryman 16y agoI remapped esc to jj based on some excellent blog post I recently read and I love it. Will get the link or post how if anyone is interested.
- SkyMarshal 16y agoWas it this one: http://news.ycombinator.com/item?id=1687701 http://news.ycombinator.com/item?id=1687701 I did the same thing, based on that post. Edit: er, maybe not that one, can't find it in the page. Could have sworn that was it though...
- ed 16y agoProbably this one: http://news.ycombinator.com/item?id=1710702 http://news.ycombinator.com/item?id=1710702 That's where I picked it up, too :-) Incidentally I also remap jh to write & exit insert mode (inoremap jh <ESC>:w<cr>). This turns out to be super helpful for web development, which often requires that you hop over to a browser after modifying code.
- tel 16y agoIt may not have quite the same effect but :au FocusLost * :wa should autosave when you switch to the browser without requiring keypresses.
- graywh 16y agoOnly when using gVim.
- thecoffman 16y agoThis gets annoying sometimes if you're working in an unnamed file. If you haven't saved yet, or don't intend to (just a scratch buffer or something) it throws an error every time you switch contexts.