Hi Andy!
On Mi, 04 Jan 2012, Andy Wokula wrote:
> Am 04.01.2012 19:52, schrieb Christian Brabandt:
> >Hi Bram,
> >I noticed a strange behaviour today when using the d command.
> >I was deleting several lines with a motion that selected the last non
> >blank on a line. Surprisingly, this deleted the whole line. After
> >searching the help, I found it explained by this paragraph in the help:
> >
> > An exception for the d{motion} command: If the motion is not
> > linewise, the start and end of the motion are not in the same line,
> > and there are only blanks before the start and after the end of the
> > motion, the delete becomes linewise. This means that the delete
> > also removes the line of blanks that you might expect to remain.
> >
> >So I tried the suggestion, made at :h o_v
> >
> > When used after an operator, before the motion command: Force
> > the operator to work characterwise, also when the motion is
> > linewise. If the motion was linewise, it will become
> > |exclusive|.
> > If the motion already was characterwise, toggle
> > inclusive/exclusive. This can be used to make an exclusive
> > motion inclusive and an inclusive motion exclusive.
> >
> >But surprisingly did not work. So I propose the following fix:
> >
> >diff --git a/src/ops.c b/src/ops.c
> >--- a/src/ops.c
> >+++ b/src/ops.c
> >@@ -1648,6 +1648,7 @@
> > && !oap->block_mode
> > #endif
> > && oap->line_count> 1
> >+&& !oap->motion_force
> > && oap->op_type == OP_DELETE)
> > {
> > ptr = ml_get(oap->end.lnum) + oap->end.col;
> >
> >regards,
> >Christian
>
> What do you mean? Example text:
>
> abc
> def
> ghi
> jkl
Provided that there is some trailing white space behind each item.
(In my example, the . will represent whitespace)
> With cursor on "def", typing
> d2e
> results in
>
> abc
> jkl
>
> and typing
> dv2e
> results in
>
> abc
> i
> jkl
This makes the e movement exclusive. And therefore, it won't delete the
i.
>
> According to the docs, it "works" for me, I think.
Now use d/i/e+ you get
abc.
jkl.
(that is expected) but I wanted to get
abc.
.
jkl.
So I thought using v would force the motion to be characterwise, e.g.
dv/i/e+ you get that result, but instead you still get
abc.
jkl.
The offset doesn't work here. Either you remove the i and the complete
line or you keep the i with the trailing whitespace.
There is no way, to remove the i but include the whitespace.
(The reason I noticed is, I am trying to map the f to a function that
works like f, but works on several lines, so I am mapping the f to some
search function and for the above example that fails).
regards,
Christian
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php