A web developer’s diary

April 24, 2007

Vim Quick Tips – Cheat Sheet

Filed under: Vim — Celia @ 9:29 am

Thanks to those who wrote all nice tips in Vim.org, I am beginning to love my editor more and more. Here, I have noted down some quick tips that I found at vim.org 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
CMD

: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

October 28, 2006

^M problem in Editors

Filed under: Vim — Celia @ 9:27 am

If you are one of those kinds who shuttle between environments like windows/linux/mac, you would have come across this problem many a times.

You would have just received a file from one of your mac friend and when you open it, you would see the file being elegantly decorated by the ^M character at the end of each line.

Well, its not really the ^M character. This happens when the editors can’t interpret the linefeed characters properly. But we can’t keep living with this character. Can we? But how to replace this to null in the file?

Try out this simple command in the command mode.

:%s/^M$//g

Note: The ^M is not carot M. It is CTRL V CTRL M.

Blog at WordPress.com.