Thursday 10 November 2005

Remove ^M from end of each line in Vi

Sometimes you might want to remove a character like '^M' from the end of each line in a vi file. This '^M' character is usually intrduced in the file if you transfer the txt or csv file from a windows environment to unix. It is the extra carriage return introduce in the end of line.

The command to do that is like this in Vi:


but to get the ^M you must press ctrl+v, then ctrl+m on your keyboard when at the vi prompt... it is one of those things