Thursday, March 5, 2020

Re: Reformatting each line independently (how to apply an operation to each line)

On 2020-03-06, 'J S' via vim_use wrote:
> Every so often, I have the need to reformat a text in such a way
> that each line gets fed to the reformatter (e.g., gqq) by itself.
> I.e., I don't want to reformat the whole text as a single block.
>
> Is there any general way to say "Do this thing (gqq) to each line?"
>
> I have found a workaround, which is to learn a macro (qq) to be
> gqq<cr>, then do:
>
> 30@q
>
> (assuming 30 is enough)
>
> This works, but it seems like there should be a cleaner way - that
> doesn't involve learning a macro.

How about this?

:g/./normal gqq

According to ":help normal-range", the following should have worked,
too, but it didn't include the last line(s) of my test file when
gqq split earlier lines .

:%normal gqq

Those reformat the entire buffer. You can change the range to suit.

Regards,
Gary

--
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20200306012543.GA24028%40phoenix.

No comments: