search and replace in VI

Hi,
I want to searcha nd replace a string in file. I am using VI I tried d comm

:s/search_string/replacement_string/g

but it is giving me " string not found" i know for sure the search_string is there in file.

please help me how to do this

thanks,
Firestar

Maybe you can do it with sed:

sed 's/search_string/replacement_string/g' file.txt > new_file.txt

---------- Post updated at 13:14 ---------- Previous update was at 13:13 ----------

Depending on the platform, you must use "sed -e", and to edit the file "in place", add the "-i" option to sed.

No matter the mechanism, you have to be specific to find the string you are searching for. Case matters in most cases. The number of whitespaces. Special characters that have to be dealt with.

Can you give us an example of what you are looking for?

what is your "search_string" ?

That command would be applied only to the line where the cursor is resting on, or in other words, the range is the current line. To search the totality of the file, you must give it a global range.

:% s/search_string/replacement_string/g

or

:1,$ s/old/new/g
 :%s/search/replace/g