View Full Version : Stripping "^M" characters
ichbin
10-23-2002, 07:33 AM
Hi,
I love using 1st Page to create and modify my web pages. However, I sometimes need to do a quick modification on a unix box and when I open the files up in vi, I have all the nasty ^M characters that screw up the code when I save in vi.
Is there any way to strip these characters out so that I won't run into this problem?
Thanks!
Christine.
Here the command I found on the web site.
Search and replace
You can use vi to search your file buffer for a text string and replace each occurrence with new text. For example, to replace "halliard" with "halyard," in edit mode type:
:%/s/halyard/halliard/gc
Vi searches the file for "halyard." You'll see each occurrence in context. Press y and then ENTER to replace the word and continue, or press n and then ENTER to continue searching without altering the text. (To stop a search in progress, press ESC.) When done, vi prompts you to press ENTER. Vi now displays the file buffer with the changes in place.
You can also search and replace without confirmation. For example, in edit mode type:
:%/s/halyard/halliard/g
Vi searches and replaces each occurrence. However, it does not ask you to approve the changes.
Hope this help
DCElliott
10-23-2002, 02:57 PM
Long time ago for me and Unix but isn't ^M the carriage return character? It must be displaying a ^ and a M rather than the CR that they represent.
I think you can create a command that will map the replace sequence to a specific command key like this:
:map v %/s/^M/whatever/gc
DE
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.