Showing posts with label vim. Show all posts
Showing posts with label vim. Show all posts

Wednesday, May 26, 2010

Avoid Kmail Editor And Use Vim Editor Instead

Kmail has bad editor when it comes to sending patches inlined. More often the message gets mangled (word wrapped). To overcome this problem Kmail allows the use of external editor.

1. Settings->Configure Mail and Click on Composer
2. Click on "Use External Editor" and specify the editor as "xterm -e vim -f %f"
3. Click Apply.

Open the composer and type in mail id and subject and click on the body. When you start typing a new editor window opens up which is vim. Type in your message and type ":wq". Thats it.

For people intending to send patches, use :vsplit and use visual method to highlight and 'y' to yank the highlighted message. Close the vsplit and type "p" to paste it.

Monday, June 16, 2008

Removing trailing whitespaces

Removing white spaces entirely from a large file can always be a pain.
Here is a simple sed command (inside vim ) that removes it in one shot

:%s/[ ^I]*$//g

NOTE: The ^I is a special character, and is generated by pressing the TAB key

vim+sed scripts to conform a file to coding standards

I have created sed scripts (that run within vim) which can fix up your source code file to conform to coding-style of the kernel.

This one adds space after every comma:
:%s/,\([^ ]\)/, \1/g

This one adds space before and after every +=,==
:%s/\([^ ]*\)\([+=]\+=\)\([^ ]*\)/\1 \2 \3/g

Stay tuned for more!