On 11/21/11 05:11, Graham Lawrence wrote:
On Sun, Nov 20, 2011 at 1:12 PM, Tim Chase<[email protected]>  wrote:
  ...:b#<cr>:0sil! /<c-r>0i

and just prefix the search/silent command with the line number from which
you want to start (either "0" in my example, or possibly "1"; difference
being what happens when a match occurs on the first line of the file and
subsequent lines of the file).

Thanks for your help, a starting line number for the search is a nicer
solution; I was under the impression that a single number preceding a
search was a count of the number of lines to search starting from the
cursor position.

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

PS: remember to CC the mailing-list (usually your mailer's "Reply All" or "Reply List") or others won't be able to contribute answers or correct me if I biff something up.




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