Unix – vi mini cheat sheet

String Replacement

:1,$/s/String1/String2/g

Yanking

y9y (with : ) -> kopies current and next 9 lines
p -> pastes the kopied mentioned lines

Yanking using vi – adding files together – copy 30000 lines

30000 yy

yy30000

The Yank Command

yy
    make a copy of the current line and place it in the General Purpose Buffer
"gyy
    make a copy of the current line and place it in the named buffer g
"a5yy
    copy the next 5 lines and place them in the named buffer a

The Put Command
p
    Will put the contents of the General Purpose buffer after the current character or line
    (depending upon whether the buffer contains a character, word or line).
"gp
    Will put the contents of the named buffer g after the cursor
"aP
    Will put the contents of the named buffer a before the cursor

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *