Monday, September 19, 2011

Numbered buffers in Vi

Been so long since the last post on Vi! Now time for another post! especially after my colleagues had trouble with named and numbered buffers!

If you haven't already taken a look at the earlier posts on Vi, here's what you need!

Named buffers are already discussed. It's now time for the numbered ones. I haven't  elucidated on the numbered ones.. so here goes!

Unlike named buffers, in numbered ones you can't decide, into which of the numbered (1-9) buffers your text goes. Because it's done automatically. When you delete or yank(copy) text without mentioning the named buffers, it automatically gets pushed into the 1st buffer referred by 1. So the recent buffer is always 1.

When another operation of yanking or deleting follows at a later time, whatever was already in 1, goes to 2 and the most recent one gets to 1. More like a stack!

Good! Now what if whatever was in 1 has gone down to 9... after 9 successive cuts/copies?! The 10th ie the recent most copy will move to 1 as said and whatever was in 9 gets lost, since 8 has now moved over to 9! Now that end is a FIFO!

Why do I need something over which I don't have control of! "What use?" you shall ask?! Now it's very much useful because if you happen to need your 2nd to recent cut/copied text... (previous to the recent cut)

Simple!

"2p

Done! third?!

"3p

and down to 9! Happy coding! or rather editing (who says vi is for coding only ;) )! 

No comments:

Post a Comment