Tuesday, June 2, 2009

Removing unwanted space in vi

Sometimes when you copy and paste some lines to vi editor, it will add some unwanted white space in the front. In that case you can execute the following commands to make it correct:

Delete all trailing whitespace (at the end of each line) with:

:%s/\s\+$//

Delete whitespace at the beginning of each line:

:%s/^\s\+//

No comments:

Post a Comment