Wednesday, September 5, 2018

Re: How do I delete from the end of the line through space (up to) the first word?



On Tue, Sep 4, 2018 at 4:51 PM 'Grant Taylor' via vim_use <vim_use@googlegroups.com> wrote:
On 09/04/2018 05:27 PM, Gary Johnson wrote:
> The best way to move to the first space on a line is to move to the start
> of the line, then find the next space to the right.  The best solution
> to your problem that I know of would be this:
>
>     ^f D

Interesting idea.  It makes perfect sense.

It also solves the problem as I described it.

I would still like to know how to delete backwards {t,T}o a word, not
{f,F} on a character I'd like to keep.

I've got all sorts of things like the following:

aaa bbbb ccccc ddd eeeeeee ffff

Where the cursor is on the last f and I want to delete from the last f
up to but not including the last d.  I.e. "Td".

But, "Td" leaves the last f there.

Could not you just move right one character and do the "Td" (kind of like
"Tdx", but moving right can be done easily with the space bar). Anyway,
to move beyond the last character in line, though, you will have to set:
    :set virtualedit=onemore

Alternatively, have you considered recording/macros?
    :h complex-repeat

You could just record a set of key strokes using the "q" command and
recall the sequence whenever you want.

Regards,
-Arun


I suppose I could use "Tdx".

I figured that there was a Vim movement that I'm not aware of.

> Any other solution that tries to find the first space by working
> backwards from the end of the line is going to require more typing,
> unless you create a macro for it.

Ya.  I'm not as worried about the "first space" as I am going backward
and deleting as I go with something like gE.



--
Grant. . . .
unix || die

--
--
You received this message from the "vim_use" 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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
--
You received this message from the "vim_use" 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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment