How to replace String "a" with String "b" in whole file of
the vi editor?

Answers were Sorted based on User's Feedback



How to replace String "a" with String "b" in whole file of the vi editor?..

Answer / mukesh nagora

:%s/a/b

Is This Answer Correct ?    41 Yes 6 No

How to replace String "a" with String "b" in whole file of the vi editor?..

Answer / debjyoti mukherjee

:g/string1/s//string2/g

ex:
:g/a/s//b/g

Is This Answer Correct ?    45 Yes 15 No

How to replace String "a" with String "b" in whole file of the vi editor?..

Answer / kasani

:%s/a/b/g

where a is old string
b is new string

Is This Answer Correct ?    22 Yes 3 No

How to replace String "a" with String "b" in whole file of the vi editor?..

Answer / bhargav

:%s/a/b/g

Is This Answer Correct ?    10 Yes 2 No

How to replace String "a" with String "b" in whole file of the vi editor?..

Answer / jp

The answer given by Mukesh would only change the first word
in each line.
So change has to be global... so add /g to it.

Is This Answer Correct ?    8 Yes 2 No

How to replace String "a" with String "b" in whole file of the vi editor?..

Answer / srikanth

suppose from begin to end

:1,$s:/a/b/c:/e/f:g

Is This Answer Correct ?    7 Yes 2 No

How to replace String "a" with String "b" in whole file of the vi editor?..

Answer / gaurav verma

:1,$ s/a/b/g

Is This Answer Correct ?    0 Yes 0 No

How to replace String "a" with String "b" in whole file of the vi editor?..

Answer / unknown

:m,n s/a/b/g

Is This Answer Correct ?    0 Yes 0 No

How to replace String "a" with String "b" in whole file of the vi editor?..

Answer / deepti

current path= /a/b/c/ -- new path= /e/f/

:%s/a\/b\/c/e\/f

Is This Answer Correct ?    1 Yes 2 No

How to replace String "a" with String "b" in whole file of the vi editor?..

Answer / nikhil vasishta

try this.
current path= /a/b/c/ -- new path= /e/f/

:%s/a\/b\/c\//e\/f\//g
where g = global (wherever the current path comes it will
change it to new path).

Is This Answer Correct ?    4 Yes 7 No

Post New Answer

More Vi Editor Interview Questions

what are the different delete commands used in vi editor?

2 Answers  


what are the two different modes in vi editor?

7 Answers  


what is the command used to delete current line in vi editor?

2 Answers  


How to replace String "a" with String "b" in whole file of the vi editor?

10 Answers   Niksun,


what is the command used to append to buffer?

0 Answers   IBM,






what is the command used to append text after current line?

3 Answers  


What is the difference between lettered buffer and temporary buffer?

2 Answers  


How to create a .exrc file in vi editor?

1 Answers  


What is the format of vi command?

2 Answers  


Which command is used to replace many characters?

4 Answers  


What is the command used to replace many characters?

2 Answers  


what is the command used to set margin in vi editor?

2 Answers  


Categories
  • Vi Editor Interview Questions Vi Editor (21)
  • Visual Studio IDE Interview Questions Visual Studio IDE (207)
  • Editors AllOther Interview Questions Editors AllOther (1)