Vim: join lines by replacing ^M
I have a file which has embedded `^M` characters. I wish to join the lines at the `^M` character.
ie: change this:
^M
être, ^M
étant, ^M
été,Indicatif,Présent,suis,es,est,sommes,êtes,sont
^M
être, ^M
étant, ^M
été,Indicatif,Imparfait,étais,étais,était,étions,étiez,étaient
to this:
être,étant,été,Indicatif,Présent,suis,es,est,sommes,êtes,sont
être,étant,été,Indicatif,Imparfait,étais,étais,était,étions,étiez,étaient
This command removes the `^M` but the lines are not joined:
%s/\r//g
`^M` is a Windows-specific EOL (End Of Line) and it consists of two characters: carriage return `\r` and new line `\
`. So you must include _\
_ in your replace command as well:
`%s/\r\
//g`
If you want to stick with you original replace command, then you must first convert EOL-format of your file from Windows one to Unix one. You can use _dos2unix_ tool to do that:
`$ dos2unix fileToConvert`