• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 680
  • Last Modified:

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'
0
Thaidog
Asked:
Thaidog
  • 3
  • 2
  • 2
  • +2
3 Solutions
 
farzanjCommented:
:%s/something/something_else/g

Open in new window

0
 
omarfaridCommented:
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 MVETopic 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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
madunixChief Information Security Officer Commented:
0
 
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

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

  • 3
  • 2
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now