Hi, Eric Leenman wrote: > > I have a long file which contains like: > ################################################## > | 0 1 2 3 4 5 6 > ################################################## > Line 18 | 123 > Line 19 | abc > -------------------------------------------------- > Line 332 | xyz > ################################################## > | 0 1 2 3 4 5 6 > ################################################## > Line 18 | 641 > Line 19 | GHI > -------------------------------------------------- > Line 332 | vcx > ################################################## > | 0 1 2 3 4 5 6 > ################################################## > .... > > How do I sort this file so that > - all line 18 , i.e., comes under each other? And line 19 , and so on. > - removes the lines starting with ### > - removes the lines starting with --- > - removes the lines starting with spaces > > So that what remains look like this: > ... > Line 18 | 123 > Line 18 | 641 > Line 19 | abc > Line 19 | GHI > Line 332 | xyz > Line 332 | vcx
:g/^\(###\|---\| \)d :%!sort Note that the final order of lines with same numbers depends on the whole line -- Lines with more spaces after "Line ### |" will come out first. Regards, Jürgen -- Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us. (Calvin)
