Monday, June 4, 2012

Re: Repeat gq from : command line?

On Monday, June 4, 2012 12:20:08 PM UTC+12, howardb21 wrote:

> let me know why these commands do not work:

As well as what Tim said, firstly the current line is always less than or equal to the last line. Surely you mean

while line(".") < line("$")

but there's no guarantee that the cursor should ever move to the last line. Also \L matches anything that's not a lowercase character, including whitespace and punctuation.

Assuming you meant

while line(".") < line("$")
:/^[[:lower:][:punct:]]\{3,}/normal gq/^\L^M
endwhile

This works, I think, if the last line matches /^\L/.

Anyway, I bet you've got wrapscan set, so that the search wraps round the beginning of the file, and so never fails, stopping the loop.

The usual way to do this sort of thing is with the :global command:

:.,$g/^[[:lower:][:punct:]]\{3,}/normal gq/^\L^M

Regards, John

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

No comments:

Post a Comment