Saturday, April 3, 2010

vi has a clipboard too!


The very interactive(vi) editor has all that your GUI based editor has! Actually, it has more! Adding to all the basics, here are some key-taps that can help u tap the power of VI.

When you hit 'd' based delete commands like 'dd', 'nd' ... or 'y' based yank commands all that's is deleted or yanked is stored in a buffer. (Ssh! Deleting with d is not delete, it's actually 'cut'. Try 'p'-ing to paste after 'd' :) )

So where does it actually get stored? It's not one but 2 buffers!

Deleted lines are stored in a numbered buffer, named from 1 to 9. (stack like. recent entry is 1, oldest being 9)
You can yank/delete into alphabetically named buffers too (a-z).

"(double quote) is used to access this a-z buffer.

" is the simple syntax

Eg: "c5dd will delete/cut 5 lines in to buffer named 'c'

(simply 5dd will not cut into the buffer)

Interesting part is "C3dd will append your now-deleted 3 lines to your previously present contents of buffer 'c'. (Note the upper case.) You can't do this even in MS word!!!

Paste the buffer using "cp     ( "c for accessing buffer and p for paste/put )


Same works for yanking too!

To access the numbered, deletion buffer, use "np where n is number 0-9 similar to a-z.

Ain't that something!!!!

2 comments: