vi and special character removal

To the group, when I copy text from a web page that has the below java code , and then do the set list command in the vi editor, I see the $ symbol at the end of each line. I have searched the internet looking for a way to remove this from the file since it will not compile without errors..Please help...

thank you

steve

class TapeDeck {$
boolean canRecord = false;$
void playTape() {$
System.out.println(�tape playing�);$
}$
void recordTape() {$
System.out.println(�tape recording�);$
}$
}$
class TapeDeckTestDrive {$
public static void main(String [] args) {$
t.canRecord = true;$
t.playTape();$
if (t.canRecord == true) {$
t.recordTape();$
}$
}$
}$

I think:

:set nolist

But those "$" characters are not really part of the file. They are just vi's indication of the end of the line.

While that makes it appear to go away (i.e.: not displayed anymore in the vi editor), I know it is still there, since when I try to compile the file it shows errors related to these characters being there still. thanks anyway, any other thoughts?

Try in vi, type:

:s/^M$//

Where the ^M$ is generated by typing press Ctrl-V then Ctrl-M.

You might need to do this:

# IN DOS ENVIRONMENT: convert DOS newlines (CR/LF) to Unix format.
# Can only be done with UnxUtils sed, version 4.0.7 or higher. The
# UnxUtils version can be identified by the custom "--text" switch
# which appears when you use the "--help" switch. Otherwise, changing
# DOS newlines to Unix newlines cannot be done with sed in a DOS
# environment. Use "tr" instead.
sed "s/\r//" infile >outfile # UnxUtils sed v4.0.7 or higher
tr -d \r <infile >outfile # GNU tr version 1.22 or higher

Which you can get from this source:

sed.sourceforge.net/sed1line.txt

Let me know how it goes!

Unfortunately this dis not find the pattern I wanted to delete (the dollar sign $)...it said pattern not found.

Give these error messages.

awk '{print $1, $2}' myfile.txt

should be able to read the first two fields without boogers. increment the $3,$4 to step through the fields.