Tuesday, September 4, 2018

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

On 09/04/2018 05:16 PM, Tim Chase wrote:
> I'm having a little trouble parsing (1) where the cursor is (it
> sounds like you're describing it at the last "t" of the first line)

Yes, the cursor is on the last t at the last character of the line.

> (2) what you want the final results to be. Do you want
>
> example.net <-- actually importan.example.com <-- not actually important
>
> or
>
> example.net <-- actually importan<-- not actually important

No, I want to end up with the following:

example.net
different.example.com

> Or are the "<-- ..." meta-commentary and not actually content in the file?

No, the actual content includes the ""arrow and what you're calling
meta-commentary. That (and the proceeding space) are what I wanted to
remove.

> It would help to have unannotated "before" and "after" and "where is
> the cursor".

Before:

"""
example.net <-- actually important
different.example.com <-- not actually important
"""

After:
"""
example.net
different.example.com
"""

Background is I was copying and pasting content from an email (including
annotations) from a friend about domains I'm configuring for him. I
wanted to get just the domain names first \W of the line and enter them
into my /etc/mail/local-host-names file.

I was editing /etc/mail/local-host-names in vim, copied and pasted the
content from email into the terminal, and wanted to remove the annotations.

> Also, is this a one-off thing where you're trying to optimize something
> manually, or should this be automated across all lines (or lines matching
> some condition) in the file? (noting that a :s command can be repeated
> with either "@:" or "&" or "g&" depending on intent)

This was a one-off. But I would like to learn the vim methodology to
play Vim Golf next time I need to do it.

I have frequently (monthly if not more often) needed to do a delete with
something similar to a "gE", but stop before the word.



--
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.

No comments: