View previous topic :: View next topic |
Author |
Message |
josephgrey n00b
Joined: 11 Jul 2007 Posts: 14
|
Posted: Sat Dec 13, 2008 3:06 pm Post subject: vim search an replace^M Not working for me.^@ |
|
|
I have obtained a file with many "^M" characters where newlines should be.
I've tried
That is --
:s/[control-v][control-m]/\n/g[enter]
vim finds all the ^M characters and replaces them with ^@.
I can replace the ^M with \t and the characters turn into tabs. If I then attempt to turn the \t's to \n's they turn into ^@'s. So, its some kind of problem with substituting the newlines.
I think this worked for me at one time. I must be doing something incorrectly. Could someone help me out? |
|
Back to top |
|
|
cwr Veteran
Joined: 17 Dec 2005 Posts: 1969
|
Posted: Sat Dec 13, 2008 4:28 pm Post subject: |
|
|
If you're cleaning up a DOS file, one approach is:
:%s/.$//
Will |
|
Back to top |
|
|
ppurka Advocate
Joined: 26 Dec 2004 Posts: 3256
|
Posted: Sat Dec 13, 2008 4:53 pm Post subject: |
|
|
Code: | :set fileformat=unix
:w |
_________________ emerge --quiet redefined | E17 vids: I, II | Now using kde5 | e is unstable :-/ |
|
Back to top |
|
|
josephgrey n00b
Joined: 11 Jul 2007 Posts: 14
|
Posted: Sat Dec 13, 2008 6:19 pm Post subject: |
|
|
Both of those commands result in the same thing--^M's turn to ^@'s.
I don't know what the deal is. |
|
Back to top |
|
|
ok Guru
Joined: 11 Jul 2006 Posts: 390 Location: germany
|
Posted: Sat Dec 13, 2008 10:50 pm Post subject: |
|
|
Code: | :s/^M/^M/g
:s/[control-v][control-m]/[control-v][control-m]/g[enter] |
works for me, don't ask why.. |
|
Back to top |
|
|
momofuku n00b
Joined: 16 Jan 2007 Posts: 3
|
Posted: Sat Dec 13, 2008 11:10 pm Post subject: |
|
|
Instead of [ctrl] + M you should actually press [ctrl] + v + [enter].
OR :%s/\r//g
Hope this helps |
|
Back to top |
|
|
yabbadabbadont Advocate
Joined: 14 Mar 2003 Posts: 4791 Location: 2 exits past crazy
|
Posted: Sat Dec 13, 2008 11:19 pm Post subject: |
|
|
Code: | emerge dos2unix
dos2unix filename
|
|
|
Back to top |
|
|
|