You are here: Hello world / Howto / VIM is your friend   How VIM makes your life easier.

VIM is your friend

This is a collection of some VIM related stuff. If you cannot find what you are looking for, try my links related to VIM.

Converting files

Note: The following conversion commands can only be applied to a single file. Use some shell loop functions to convert many files at once.

Warning: Be sure to have a backup copy of your file!

From DOS to Unix

Strip all carriage-return characters.

$ vim +'%s/^M//' +wq filename.txt

Note: Use the sequence Ctrl+V,Ctrl+M to enter that ^M.

From Mac to Unix

Replace all carriage-return characters by a newline character.
Note: It seems that Mac OS X does not need this conversion, at it already uses the unix way of ending a line.

$ vim +'%s/^M/^M/' +wq filename.txt

Note: Use the sequence Ctrl+V,Ctrl+M to enter the first ^M. Use the sequence Ctrl+V,Enter to enter the second ^M.


Author: Tobias Jahn
Public key fingerprint: 0556 B7D8 93FB 0304 B868 9FBA 3A71 E4F9 AE03 4AAD
Last modification of this page: 2002-01-06 13:27 GMT
Last generation of this page: 2007-06-16 20:26 GMT
Valid HTML 4.0!