What is the vim command equiv to: sed -i 's/something/something_else/g'

When inside vim, what is the ex command equiv to: sed -i 's/something/something_else/g'
LVL 1
ThaidogAsked:
Who is Participating?
 
farzanjConnect With a Mentor Commented:
:%s/something/something_else/g

Open in new window

0
 
omarfaridConnect With a Mentor Commented:
while in command mode (you can press ESC key to be in command mode), you type

:1,$ s/something/somthing_else/g

and then hit enter key
0
 
Gerwin Jansen, EE MVEConnect With a Mentor Topic Advisor Commented:
Both above are correct, -i also writes changes to the file so above command to be followed by:

:wq
or
:ZZ

Followed by enter
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
serialbandCommented:
You could also replace the "1,$" with a single "%"

:%s/something/somthing_else/g
0
 
Gerwin Jansen, EE MVETopic Advisor Commented:
@serialband - That is exactly what farzanj suggested in http:#a38308745 - please read earlier comments :)
0
 
serialbandCommented:
I did read the earlier comment.  I added a different syntax which reduces 2 keystrokes that did the same thing.  If you need to search& replace a lot of text, fewer keystrokes are better, at least it is for me.
0
 
farzanjCommented:
gerwinjansen is right.  I don't see any two character difference:)
0
 
serialbandCommented:
Maybe your fonts show the percent sign too large so you see it as 3 characters?  :P  O/o
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.