On Mon, Nov 21, 2011 at 4:44 AM, Tim Chase <[email protected]> wrote:

> In normal-mode, the number prefixing a search is a count, to find the Nth
> match.  In command-line mode (entered when you hit the colon), it's the line
> at which to start.
>
>> But one thing still puzzles me: in fact, I had tried each of gg, 1G
>> and cursor with and without a leading<:>, with and without a trailing
>> <space>, with and without a trailing<CR>; and, as I originally wrote
>> the script, it read
>>
>> :map p$ ggdd:while @" != ""<CR>:b#<CR>gg:silent!
>> /^R"<CR>0i$<Space><Esc>:b#<CR>dd:endwhile
>>
>> in which the first gg works, the second gg fails with E492, and I
>> would very much like to know why.
>
> Strange things happen when you mix command-line mode and looping.  When you
> start the ":while", Vim starts a command-entering mode waiting for the
> "endwhile".  Thus the ":" before the "b#" is optional, and the "gg" is then
> treated as an Ex command (triggering the E492).
>
> -tim
>
Thank you very much, that makes it very clear, and also resolves
another thing that had been bugging me.  Somewhere I had got the
notion that <:> was optional in scripts, kept encountering situations
where it was not true, and took to colon-izing everything as it would
be in the buffer command line.  But actually the <:> is optional only
if the script is implicitly in command mode due to a previous command,
like a loop structure.  So presumably one would also be in the same
situation using a | separated string of commands in the command line;
they could be of the form
:command1 | command2 | command3... <CR>
and the initial <:> would extend to subsequent commands on the same
line.  And presumably any normal mode commands in such string would
fail unless prepended by <normal >

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

Reply via email to