Tim Chase wrote:
is there a way to yank in ex-mode? I want to find all
\d\d\d\d  in my file and put them in the end of their
containing line.

1) yes, you can yank in ex-mode, though it usually happens in line-wise fashion, unless you pull some stunts to prevent that:

    :10y

will yank line #10 into the default register.

    :let @a=''|g/regexp/y A

will pull all the lines matching "regexp" into register "a"

To do just piecewise bits into a register, you can use

:let @a=''|g/regexp1/let @A=substitute(getline('.', '^.\{-}\(regexp2\).*$', '\1', '')

which is ugly and hackish, but will pull one piece matching "regexp2" from lines matching "regexp1" and tack them into register "a" (you can append

    .'\n'

IIRC, to put each piece on its own line in the register)


2) If you just want to move that pattern to the end of the line, you can use

    :%s/\(\d\d\d\d \)\(.*\)/\2\1

If you want to copy (rather than move) the contents to the end of the line, you can use

    :%s/\(\d\d\d\d \).*/&\1

If you want extra space between what was formerly the EOL and the added text, just add a space before the \1

Just a few ideas...

-tim





:%s/\(\d\d\d\d \)\(.*\)/\2\1

works fine. Thanks!

Reply via email to