Removing Carriage Returns the Easy Way using vi

Frequently, when working in a Unix environment, i will get files that have carriage returns at the end lines that i would like to remove. There are a million different ways to remove them, but this is the simplest way i have found if you are familiar with vi or vim. Use the substitution command to remove them by putting a control ‘v’ followed by a control ‘m’ in the pattern to be matched in the vi command.

:%s/<ctrl>+v<ctrl>+m//g

June 9, 2009   Posted in: System Adminstration

Leave a Reply