Removing ^M characters on ubuntu in VIM
Posted in
Ubuntu / Linux
on Nov. 6, 2010, 1:16 p.m.
It took me a while to figure out how to get rid of pesky ^M characters in VIM on ubuntu. ^M in VIM can be manipulated as it is an \r character. Often times other developers would edit python files in gedit or notepad and ^M characters would be inserted. I could not simply %s/\^M//g as “^M” was not a recognized character.
The fix is really quite simple and I was frustrated it took me so long to find, but in case it gets to anyone else – the ^M is a line feed character that is inserted by gedit(among other editors) sometimes. In VIM, it shows up as ^M, but it is actually a “\r” character. So, doing a replace for \r characters will remove the ^M
The fix is really quite simple and I was frustrated it took me so long to find, but in case it gets to anyone else – the ^M is a line feed character that is inserted by gedit(among other editors) sometimes. In VIM, it shows up as ^M, but it is actually a “\r” character. So, doing a replace for \r characters will remove the ^M
%s/\r//g
RSS Feed
Subscribe to the RSS FeedCategories
- All Categories (13)
- Game Development (2)
- Miscellaneous (0)
- MooTools (2)
- My OpenLayers Book (2)
- OpenLayers (4)
- Ubuntu / Linux (3)