LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-04-2006, 07:53 PM   #1
otacon 14112
Member
 
Registered: Apr 2004
Location: /
Distribution: ubuntu (gutsy)
Posts: 46

Rep: Reputation: 15
Simple question about the vi text editor


Hello,

Is there a way to search for all words of a certain string and replace all instances of that search string with a different string? I did this once but I completely forgot how to do it. There is a way to do it in one command, and I can't remember what it is. It's really irritating me that I can't remember it!

If someone could show me how to do it I would greatly appreciate it!

Thanks,
Otacon
 
Old 10-04-2006, 07:57 PM   #2
dive
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Slackware
Posts: 3,467

Rep: Reputation: Disabled
:%s/string/replacement/gc

The gc on the end make it global and ask for confirm. You are better off using vim because the confirm feature is better than vi.

Last edited by dive; 10-04-2006 at 07:59 PM.
 
Old 10-04-2006, 08:00 PM   #3
otacon 14112
Member
 
Registered: Apr 2004
Location: /
Distribution: ubuntu (gutsy)
Posts: 46

Original Poster
Rep: Reputation: 15
Do I actually include the ampersand in the command?

Thanks,
Otacon
 
Old 10-04-2006, 08:01 PM   #4
otacon 14112
Member
 
Registered: Apr 2004
Location: /
Distribution: ubuntu (gutsy)
Posts: 46

Original Poster
Rep: Reputation: 15
Oh yeah, sorry, I was using vim.

Thanks,
Otacon
 
Old 10-05-2006, 12:37 AM   #5
otacon 14112
Member
 
Registered: Apr 2004
Location: /
Distribution: ubuntu (gutsy)
Posts: 46

Original Poster
Rep: Reputation: 15
Ok that worked. Thanks a lot!


Otacon
 
Old 10-05-2006, 01:32 AM   #6
loonykroons
LQ Newbie
 
Registered: Oct 2006
Posts: 11

Rep: Reputation: 0
Hi,
U can also use "sed" command for the purpose.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
A good text editor...this should be simple. TheMusicGuy Linux - Software 9 10-06-2004 12:16 AM
Good simple text editor like WinSyntax needed eBopBob Linux - Software 5 08-18-2004 03:15 PM
A simple text editor for .ps files satimis Linux - Software 13 08-12-2004 10:38 AM
Simple Guide on creating text editor in shell. xushi Programming 2 02-06-2004 01:37 AM
Just a simple text editor fr0zen Linux - Software 6 12-22-2003 12:04 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:09 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration