find and replace in vi

Posted on 2003-03-28
Medium Priority
Last Modified: 2013-12-13
hello guys,
1.how to do find and replace in vi editor??
2.how to get the man page of the particular word at which the cursor is blinking (if there r any settings to do so plz mention like exrc)
Question by:k_kalyan
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

chidamz earned 200 total points
ID: 8223714
 Open a file in vi editor ,after opening file
1. to find  just enter / this will lead u to the
end of window after
/[word u want to find]
for example to search kalyan in the file after u have opened

then press enter it will lead to word kalyan
if u press word N then it will go to next
kalyan in the file

2.to replace

 open file in vi editor
 type : it will lead to end of file with semicolon :

  :1,$  s/word to be replaced/word to be replaced with/g

example to replace word kalyan with chida
  :1,$ s/kalyan/chida/g

 here 1 denotes first line,$ denotes till last line
  s denotes string
   g denotes globally

LVL 18

Expert Comment

ID: 8223754
instead of 1,$ you can use %

Expert Comment

ID: 8236614
I'll repeat some of the comments above but I'll add my own too.

1. Find: "/search_string_here" without the quotes. If you are searching for string including slash insert backslash before that. An example: if you are looking for http://blah your search string should be:


or like liddlet mentioned above you can use:


Replace: It depends what do you want to replace. I mean single string, all strings, all strings from point to another point. If you are more specific we can help you with details. For global replace of a string use:


2. On the shell (prompt) you have to type:

man -k word

where the 'word' is the one you are looking for and you'll get a list of manual pages which are incuding that word. If they are too many you can use

man -k word | less

and list them with up/down arrow.
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.


Expert Comment

ID: 8246781
try this:


the gc is optional, g tells the line to keep looking globally through what you are editing instead of the line you are on. If you leave off the g it only searches the line you are on.

the c tells it to give you a confirmation or an "Are you sure ?" on every instance it finds.

Expert Comment

ID: 9087587
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Post your closing recommendations!  No comment means you don't care.

Expert Comment

ID: 9294529
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Accept comments from chidamz as answer
Please leave any comments here within the next seven days.


EE Cleanup Volunteer

Featured Post

PowerShell Core for Advanced Linux Administrators

Understand advanced principals around Powershell Core with a focus on the Linux Administrator.  This course covers how to administer numerous environments across multiple platforms including Linux, Azure, AWS, and Google Cloud from a single shell instance.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
Suggested Courses
Course of the Month9 days, 8 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question