Wednesday, February 8, 2012

'command-list' in 'Q' and 'gQ' ex-mode

Hello everybody,


I'd like to be able to use vim in ex-mode to do what can be easily done
with the 'ed'itor, but I just can't figure out how.

Please, let me explain what I'm trying to do:

my text looks like this:

---- snippet starting at line 13 ---

AAAAA

1

BBB

7

CCCC

11

---- end of snippet(line 27) ---

To give you an idea, I want to make a table of content which would look
like this

AAAAA.............1
BBB...............7
CCCC.............11

But for now, something like this

AAAAA.............1
BBB.............7
CCCC.............11

would be just fine:)

This is easily done with 'ed' with the following command:
13,27g/^[A-Z]/s/^/ /\
.,.+2j\
s/[0-9]\+$/.............&/

But as you can imagine, my workflow would be so much smoother if I had
not to use ed:)

in 'Q' mode, the equivalent(_I_ think) command:
:13,27g/^[A-Z]/s/^/ /\
.,.+2j!\
s/\d\+$/.............&/

gives me:

AAAAA

1

BBB

7

CCCC.............11

while in the 'gQ' mode the command:
84,96g/^[A-Z]/s/^/ /\
.,.+2j!\
s/\d\+$/.............&/

gives me the following error:
"E488: Trailing characters"

I've tried adding some space here and there to separate the commands, but I
can just not figure how to do it.

Any help greatly appreciated:)


sam

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

Post a Comment