Vim Quick Tips – Cheat Sheet

Thanks to those who wrote all nice tips in, I am beginning to love my editor more and more. Here, I have noted down some quick tips that I found at and ones that you’ll not usually find anywhere else.

I have followed a terminology here.
CMD – means command mode.
INS – means insert mode.
VIS – means visual mode.
LOC – means to be entered in .vimrc file

Mode Command Description

:lineno Go to a specific line.
CMD * Searches for the word under cursor
INS CTRL - N Autocompletes word
CMD % to jump to a matching closing/opening brace
CMD . quick copy/paste
CMD x Shortcut for save and exit (wq)
CMD @: Repeat last command
LOC iab { {CR} (Enclose CR in angular brackets) automatically adds closing brace


Javascript: Positioning the cursor at the beginning of a textarea

I had been using the textarea.focus() function and saw that it behaves differently in different browsers. If there is no content in the textarea, all the browsers behave the same and they set the cursor position at the beginning of the textarea.

However, if there is some text contained in the textarea, IE positions the cursor at the end whereas safari positions the cursor at the beginning. After some frantic google searching, I found the below javascript would fix this discrepancy.

if (replybox.setSelectionRange )

This works fine in all the browsers. Let me know if this helped you.