Thomas Michael Engelke wrote:
2006/12/6, A.J.Mechelynck <[EMAIL PROTECTED]>:
Thomas Michael Engelke wrote:
> Hello,
>
> I have found an oddity in vim which I'm not sure is a bug and/or known.
>
> I have yanked a visual block of some lines of code and try to put it
> in somewhere else. There a strange effect happens: depending on if
> there is either a character or a beginning of line left besides the
> cursor, paste via "p" works different.
>
> When I have a BOL or a char to the left, it gets pasted and uses the
> cursor position as upper left corner. When there's no char/BOL, it
> uses the char right beside the cursor position as upper left corner.
>
> It's easily reproducable by just moving the cursor one position to the
> right and paste the block again.
>
> Anybody that can reproduce the problem and/or shed some light on it?
>
> Note: Shift+P works as a workaround.
>
> Regards,
>
> Thomas
>
I don't understand what you mean.
p means "put after cursor"; P (shift-p) is "put before". Depending on
whether
the selection to be pasted is characterwise, linewise or blockwise,
the result
will be different. Now let's assume it's blockwise, and that
'virtualedit' is
off (e.g. empty). Using p inserts the selection after the cursor
character,
and after the character in the same column on successive lines. If
some of the
lines are shorter, spaces are inserted so that the block will be
inserted as a
rectangle. The exception is when the cursor is on an empty line: in
that case
there is no character at the cursor, and the block gets pasted "after
character zero", i.e., at the start of the current line and of successive
lines after that. I don't see any problem. What is it that you don't
understand?
Hello,
I'll try to elaborate here.
Sometimes, I have to align statements in a large "assign"-statement like
this:
assign
var1 =
var2 =
.
I block-yank a block containing, left-upper, v of var1, right-lower 2
of var2, to insert both variable names after the equal-signs. So my
cursor stands in the spot behind the equals on the first row. I press
p. This is what I get:
assign
var1 =var1
var2 =var2
.
I think: Oh, it gets pasted from exactly where my cursor is. I must be
standing wrong. I undo the change, go 1 spot to the right and press p
again. I end up with this:
assign
var1 = var1
var2 = var2
.
Note that there are 2 spaces after each equal-sign. that is what I do
not understand. Doing the same action, modified by 1 column to the
right, should paste the same, but all one spot to the right. Is that
assumption wrong?
Assuming that what you said hits the spot, p at the described spot
should insert the block with only 1 space between the equal-sign and
the first column of the block.
Hope this clears it up.
Regards,
Thomas
I don't see what you describe. Which version and patchlevel are you using? (as
shown by the first 4 lines of the output of ":version"; see ":help :redir"
about how to capture that output)
I'm using:
VIM - Vi IMproved 7.0 (2006 May 7, compiled Dec 5 2006 22:18:11)
Included patches: 1-178
Compiled by [EMAIL PROTECTED]
Huge version with GTK2-GNOME GUI. Features included (+) or not (-):
[...]
(The purpose of the 178 patches so far is summarized at
http://ftp.vim.org/pub/vim/patches/7.0/README )
When I hit p with the cursor at the end of a line, the first line of the block
is appended to the current line. If I undo, move the cursor one character
left, and hit p again, then the last character of the current line (and only
the last one) ends up after the block.
Note that the cursor ends up on the first character of the pasted block, i.e.,
not where it was before the paste. Undo moves it back. The fact that the
character at the cursor (before the paste) is or isn't a space changes nothing.
Best regards,
Tony.