27 octubre 2006

Buscar y reemplazar una palabra desde VI

Suppose you want to replace every occurrence of the word "idiot" with the word "manager". No confirmation needed because all idiots are managers.

Use the command:

:%s/\/manager/g

The parts of this command are:

: Enter command mode
% Perform this command on all lines (% is a synomim for the first to last line.)
s The short form of the :substitute command.
/\/ This text specifies the text we are looking for wand want. The \< tells Vim to match a word start and the \> tells Vim to match the end of a word.
/manager/ The replacement text
g Global flag -- This flag tells Vim to change every occurance on the line, not use the first one.

1 comentario:

fjimenez dijo...

Tomado de aquí:
http://www.oualline.com/vim-cook.html#replace_one