Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I used http://jmcpherson.org/editing.html as well as a cheat sheet. There's also http://vim.org/tips/ which seems to come up a lot whenever I'm searching for specific functionality. Other than that, simply immerse yourself in vim and deal with the pain for no more than a week before you'll find that you're already becoming more efficient.

Some less-commonly-used-but-awesome features:

  C-X C-F in insert mode: complete file names
  C-X C-L in insert mode: complete entire lines of code
  C-N, C-P in insert mode: complete word forward, previous
  v (V) in edit mode: entire visual mode (visual line)
  gq in visual mode: rewrap selection
  >> in edit/visual mode: indent current line/selection
  gg=G in edit mode: reformat indentation of entire file
  @@ in edit mode: repeat last keyboard macro
There's a lot I've left out (obviously), but that's a little teaser. One paradigm I use a lot is when I need to change a variable name... this is very easy. While on the variable itself, press * to search forward for it. Then type cw to erase the word and type in the replacement, followed by ESCAPE (of course). From then on, you can use n to find the next occurrence and then type . to change the name, because . repeats the last command.

Oh, and one last thing. Remap ESCAPE to CAPS LOCK, or get used to using C-[. Both are more convenient than reaching for the top corner; CAPS LOCK is superior in my experience, but it will kill you when you're on a non-mapped system.






Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: