So I am learning about vim/vi/ex and I thought I had a pretty good understanding of the buffer system. (theres a gen purpose buffer and you can also name buffers). I know that anytime you use yank, change or delete, the contents of the general purpose buffer are over written.
However, I was given a task to use a vi/ex command to delete the last 2 lines of the buffer and I am stumped. I can't seem to find the answer by searching the forums or the Internet in general so I thought I would ask the gurus of the interwebs for some help here.
Is there a way to directly modify the contents of a buffer, or is the answer simply to paste the buffer, delete the last 2 lines and then yank it again?
Any help is appreciated.
EDIT: I would like to edit this question to include the question:what is the difference between a buffer and a register?
I originally thought they were essentially the same thing, but have since learned otherwise.
My new understanding is that the things I were previously referring to as buffers are actually registers, which makes more sense according to my knowledge of computers.
Now, I believe the buffer is just the current copy of the text that you are modifying. Or more specifically, the area of main memory in which you are manipulating data. (So the answer to my question would actually just be :$-1,$d)
However, I have run into conflicting information on these forums that say the opposite, referring to "registers" as "Buffers".
If someone could clear that up I would be really appreciative.
EDIT: vim help got me all the answers I needed, can't delete the post though. It should be noted that there are a lot of answers to questions both on this site and many others that are voted up highly, but refer to registers as buffers incorrectly.
I started to write a lengthy answer but I ultimately decided to scrap it and give you the answer you deserve:
:help buffers
:help registers