LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   replace a word in vim editor (https://www.linuxquestions.org/questions/linux-newbie-8/replace-a-word-in-vim-editor-299992/)

fssengg 03-10-2005 09:17 AM

replace a word in vim editor
 
hai
I am using vim editor and i want to know how can i replace all occurance of a word with an other word? is there any built in command in vim to do this?

jxi 03-10-2005 09:24 AM

you have help in vim

while in command mode try:

:h replace

druuna 03-10-2005 09:26 AM

Hi,

In command mode:

:%s/THIS/THAT/g

This will change all instances ofTHIS in THAT. the % is the line range (% = all), you could also do this: 5,15, which will change occurences in lines 5 to 15 (included).

The g on the end makes sure that all occurences in one line are changed. If you don't use the g, only the first instance will be changed.

Take a look here for a short vi tutorial: vi tutorial

Hope this helps.

fssengg 03-10-2005 09:39 AM

thankx for ur help it solved my problem


All times are GMT -5. The time now is 12:56 PM.