Tuesday, October 12, 2010

Re: Executing commands over a fold

On Mon, Oct 11, 2010 at 9:33 PM, Ben Fritz <fritzophrenic@gmail.com> wrote:
>
>
> On Oct 8, 9:50 am, Ben Fritz <fritzophre...@gmail.com> wrote:
>> > 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
>> You're trying to execute a normal-mode command where an :ex command is
>> expected. What you are trying to do is:
>>
>> :folddocnormal! '<C-R>a'
>>

I tried this, and it says "mark unknown". I'm assuming there's a
space between folddoc and normal?

>
> (where <C-R> means "type CTRL and R keys together")
>
>> 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'
>>

I realize it's possible in visual mode. Perhaps I can try that. What's
neat about folds (assuming I can get folddoc working) is that you can
execute a command in different parts of the file, whereas in visual
mode, it's a continuous selection.

> Actually, it occurred to me, the BEST way is probably to dispense with
> the <C-R> altogether:
>
> :'<,'>normal! @a
>

I tried the folddoc with the @a, and it just wiped out the text in my
fold altogether, replacing it with what i wanted to insert. Here's
what I tried
:folddoc normal! @a

Or perhaps I'm just not understanding the point of folddoc - I thought
you could use it to execute commands in normal mode as well, but maybe
visual mode is intended for that? The code you showed did work in
visual mode.

Thanks,
Ven

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