Copiar y Pegar
y Copy text (that is, yank it into a holding area for later use). (see explanation above)
p — Paste line(s) you deleted (or yanked) back into the file. This is an excellent command if you want to move a few lines somewhere else in your file. Just type ‘3dd’ to delete three lines, for example, and then move to where you want those lines to be and type ‘p’ to paste the lines back into your file below the cursor.
3dd Lineas por copiar
CTRL L — Redraw the screen. If somebody writes to you while you are in the middle of vi and junk appears all over your screen, don’t panic, it did not hurt your file, but you will have to hold down the CTRL key and type ‘L’ to clean it up (CTRL L).
Search and Replace
/the — Finds the next occurence of «the». This will also find «their», «them», «another», etc.
?the — Finds the previous occurence of «the».
n — Repeats the last search command. Finds the Next occurence.
d/the — Deletes until the next occurence of «the». This is to demonstrate how the delete prefix can be used with any cursor movement command.
:g/oldword/s//newword/gc — This will find all occurences of «oldword» and replace them with «newword». The optional «c» at the end of the command tells vi that you would like to «confirm» each change. Vi will want you to type in «y» to make the change or «n» to skip that replacement. Great for spelling fixes.
Replace: Same as with sed, Replace OLD with NEW:
First occurrence on current line: :s/OLD/NEW
Globally (all) on current line: :s/OLD/NEW/g
Between two lines #,#: :#,#s/OLD/NEW/g
Every occurrence in file: :%s/OLD/NEW/g
Borrar la búsqueda anterior
:hi clear search