tags:

views:

101

answers:

3

I want to search some text and move the entire line where the text belongs to the beginning of the file. Just that.

A: 

Well, what I'm gonna suggest is a primitive answer as primitive it can get. But nothing else springs to mind currently.

:g/A ... some text not including A, B or C.../d

(will tell you how many lines it has yanked)

and then you go to the beginning of the file and, for example

5P

Although, if cases are as simple as this, maybe sorting lines by first letter .... I've never done anything similar but look for older questions.

ldigas
+1  A: 

:g/regex/norm dd1Gp

Martin Kopta
I must add that this is what I want: :g/regex/norm dd1GP (so it is moved above the first line. Thanks.
unkiwii
+6  A: 

How about the simple move command?

:g/^C/m0
:g/^B/m0
:g/^A/m0
Marcin
WoW! This is even better :)
unkiwii
There are lots of tricks you can do with m, like moving things to x line, or end of file... Running it twice will even reverse the ordering of the moved lines.
Marcin