Friday, October 8, 2010

Re: Executing commands over a fold

On Oct 7, 2:51 pm, Ven Tadipatri <vtadipa...@gmail.com> wrote:
> I'm really excited about the possibility about running a command over
> a set of folds. What this would mean is that I could store a command,
> then rather than trying to run it 10 times, see that I have a few more
> lines to execute, run it again, hoping that I don't go too far,
> instead I could fold the lines I want to execute the command over,
> then only execute the command over what's folded. In fact I was so
> excited, I started to add this to one of the wikia pages on folding.
> But then I was slightly disappointed to see that the "command" that
> folddoc expected didn't like my escape sequences.
>    Could you help me determine what's wrong?
> Store the keysequence into a buffer:
> qa^i    ^[ (escape key)
> Set the mark with ma, and go to the line I want to start the fold.
> Make the fold to the mark that I've set
> zf'a
> Now, the part that doesn't work:
> :folddoc <ctrl+r>a
>
> Any help would greatly be appreciated.
>

You're trying to execute a normal-mode command where an :ex command is
expected. What you are trying to do is:

:folddoc normal! '<C-R>a'

However, may I instead suggest:

1. Visually select the lines you wish to execute the command on (or
use marks as you are doing)
2. :'<,'>normal! '<C-R>a'

Note that if you press : in visual mode, the '<,'> automatically gets
inserted on the line. This means, "do the command :normal! on every
line in the visual selection".

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