Re: "gv" selection after cut-n-paste is buggy

select multilines
cut by using "x", or "d", or whatever, then move cursor, paste with "p", then "gv", it select the wrong part
expected result: the text that was paste should be selected


Re: "gv" selection after cut-n-paste is buggy

gv is supposed to select the last visual range. It is not expected to do what you describe. In my vim (7.0 for win32), gv doesn't select the just-pasted text.

Do you, or does anyone else, have an explanation as to why it does so in your system?

It's puzzling.

  - Jon


Re: "gv" selection after cut-n-paste is buggy

oops, i was wrong. but however, selecting the same range of text after text is change does not make any sense.
if (1) {
<indent>abc; (before cut)
else {
<indent>if (abc) {
<indent><indent>abc; (paste here)
see, i want to cut abc;def abofe and paste it below, and then want to select the pasted text, use > to add indent. it would be nice for gv tos elect the pasted text, not the previous text range
this is more useful for an programmer's editor (like vs) than a common editor like vim

is there any vi-er or vim-er know how to do it in vi/vim?


Re: "gv" selection after cut-n-paste is buggy


When I want to do what you've described, I usually just do the following:

* <Shift-V> to enter Visual Line mode, select the block I wish to copy/cut
* Hit y/d to yank/delete and copy the selection
* Move the cursor to the target line
* Hit p to paste the selection, <Shift-V> to select the line I just pasted, < or > to indent/unindent as required

After the first indent/unindent, you can use . to repeat it if you need to add/remove more than one level of indentation. So really, I think I'm doing exactly what you've said, except I use <Shift-V> to select the pasted text, not gv.


Re: "gv" selection after cut-n-paste is buggy

Other ways you can do it:

  * Paste using ]p so that it's auto-reindented
  * Type >'] after pasting to reindent, as the '] mark is set to the end of the paste
  * Use =iB or =i{ to reformat the "inner block" where you are (all the code between braces)

And probably more I can't think of right now!

  - Jon