Friday, June 21, 2013

Re: append to non-blank lines in a selection

Chris Lott <chris@chrislott.org> a écrit:
> On Fri, Jun 21, 2013 at 6:55 AM, Ben Fritz <fritzophrenic@gmail.com> wrote:
> > Since you don't like regex (although you're right, you should learn)
>
> It's not that I don't like regex, it's that I've found them hard to
> learn. Suggestions on good sites/books/etc to learn them would be much
> appreciated.

Perhaps you should start with some basic stuff (like "*" or "$" or
character classes) and then learn new things when you need them
(that's how I got used to regex myself). For instance, Gary and Ben's
solution might give unwanted results if blank lines contain space
characters. So your next step is "Could it be possible to match a line
that contain at least one non-space character?" and a quick look up
":help pattern.txt" gives you "\S":

:g/\S/s/$/word/

So my advice (I'm definitely no authority on that subject, mind you)
is to *use* regex and fill in the blanks stepwise; if you really don't
know anything about regex (I doubt that is true, though), then perhaps
":help user_27" might be a good starting point.

(And you definitely should use regex with Vim! Otherwise it's like a
corded drill with the power off.)

Best,
Paul

--
--
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/groups/opt_out.

No comments:

Post a Comment