Meino Christian Cramer wrote:
Hi,

 I read of a vimtip, that one can move/copy lines of a text which
 match a cvertina pattern to line 0 (top) of the text.

 This is a nice trick to gather material for a kinda quick'n'dirty
 "Table of contents" it has one drwaback: The copied lines are in
 reversed order.

 Surely it is possible to write a fairly simple function with a
counter, which keeps track to what line something is copied.
 But it would be interesting whether it is possible to achieve this
 with more "condensed" tricks without writing a function in
 beforehand.

 Thank you very much for any idea/hack/trick in advance!
Keep hacking!
 mcc


You could use the reverse lines trick to reorder the copied lines. Use the following to put the lines at the top of the file:
:let cnt=0|g/(regexp)/copy 0|let cnt=cnt+1

Then re-reverse the copied lines at the top of the file:
:exe "1,".cnt."g/^/m0"

Easy enough to put that into a function passing the 'regexp' to it...

- Dave

Reply via email to