Friday, June 21, 2013

Re: append to non-blank lines in a selection

On Thursday, June 20, 2013 11:23:39 PM UTC-5, Gary Johnson wrote:
> On 2013-06-20, Chris Lott wrote:
>
> > Given a text:
>
> >
>
> > line1 has stuff
>
> > so does line 2
>
> >
>
> > line 4 has more stuff
>
> > and line 5
>
> > and so on
>
> >
>
> > I would like to select the text block and append a word to each
>
> > non-blank line. I can use a block selection and `A` to add to all
>
> > selected lines, but not sure how to only apply to lines that have
>
> > text.
>
>
>
> I don't think there is a way to qualify an operation like A on a
>
> visually-selected region like that. However, you can so qualify a
>
> :substitute command. Select the text block and type
>
>
>
> :g/./s/$/word/
>

Since you don't like regex (although you're right, you should learn), you could alternatively do it like you've always done with A:

:g/./normal! Aword

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