On 2011-11-20, porphyry5 wrote:
> In a script, how can I get repeated searches always to begin at the start of
> the buffer?
> If I precede the search with gg  or :cursor(1, 1) I get E492, with 1G I get
> E464.
> 
> :map p$ ggdd:while @" != ""<CR>:b#<CR>:cursor (1, 1)<CR>:silent!
> /^R"<CR>0i$<Space><Esc>:b#<CR>dd:endwhile

I haven't looked closely at your mapping, but to use a normal-mode
command such as gg in a script, that is, as an ex command, you must
precede it with ":normal", as

    :normal gg

Similarly, to use a function as an ex command, you must precede it
with ":call", as

    :call cursor(1, 1)

See

    :help :normal
    :help :call

Another way to move the cursor to the first line of the buffer is to
simply put the number 1 on a line by itself, or in a mapping like
yours, as ":1<CR>".

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

Reply via email to