(Stupid plain text problem...)
Russell Bateman wrote:
Eric Leenman wrote:
Hi,
I'm used to cut, copy and paste the windows-way.
Meaning, selecting text and then press CTRL-X, CTRL-C or CTRL-V.
In VIM (and correct me if I'm wrong) you
yank (y) for copy
put (p) for paste
..... for cut
With this in mind, how to cut, copy and paste the VIM-way?
Because when I select text and see select-mode in the lowest line
and then press y, I see a letter y in my text and the selected text
is gone.
How come?
Rgds,
Eric
Eric,
Just in case you don't think Sibin's reply was what you were after,
let me answer more simply the question you asked. You were trying to
erect a naive list of equivalents between common other-world actions
and vi/Vim.
There are two ways to copy content to a buffer. y is used to yank a
copy of it (essentially leaving the text intact--what Sibin refers to
as replacing the text with itself) and d is used to delete that text
keeping a copy of it in the buffer. (I'm sorry, when I say buffer
here, I'm referring not the larger buffer between Vim and the file,
but to a clipboard. I do not myself know the correct terminology that
has grown up in the Vim community because I've always been more
interested in consumingvi/Vim as a productivity tool than in its
development.) And, yes, p for paste after, P for paste before cursor.
Additionally, and this is a delight that you do not have in Windoz,
you can choose any of many "named" buffers (clipboards if you will) to
put the text, so you can copy up a bunch of discontiguous chunks of
text into buffers a, b, c, ... etc.:
Mark the beginning of the selection (Vim has a more advanced, visual
mode for this--I'm only talking vi here) using m + some anchor mark
(anything from a, b, c, ..., z and maybe more), then move the cursor
to the end (or beginning if you marked the end) and yank or delete the
text into the buffer of your choosing:
mx
(movement commands to get somewhere else)
"ay'x (or "ad'x)
--interpreted as choose (") buffer a (a) yank (y) from mark (') x (x).
(Or, choose buffer a and delete text from current position to mark
keeping it in that buffer.)
Then you go where you want to paste the text and use the following
incantation to spit it out:
(movement somewhere)
"ap
--interpreted as choose (") buffer a (a) and put out (p). Now, if you
hadn't yanked or deleted any other text in the meantime, you didn't
need to indicate the named buffer because it would have been the last
one so you could simply have done"
(movement somewhere)
p
Last, if you use the back-tick or grave in place of the single quote
in the yank or delete commands, you will get not the whole line, but
the range of characters only. Experimenting with all of this will
quickly clue you in:
mx
(movement)
"ad`x
(movement)
"ap
Because I'm a now ancient vi user only dipping a toe intothe wonderful
world of Vim, the most beautiful, performant and fully featured editor
in the known universe, I miss out on the cooler stuff, but this is how
I've always done it.
I strongly suggest input from other Vimmers and would not mind being
corrected, put in place, growled at for being so unenlightened, etc.
Russ