Reputation: 63
Here's my situation I have numerous SQL rows like the following.
SET IDENTITY_INSERT blah
DELETE FROM blah
SET IDENTITY_INSERT blah
DELETE FROM blah
SET IDENTITY_INSERT blah
DELETE FROM blah
SET IDENTITY_INSERT blah
DELETE FROM blah
SET IDENTITY_INSERT blah
DELETE FROM blah
I want to rearrange it using VIM to
SET IDENTITY_INSERT blah
SET IDENTITY_INSERT blah
SET IDENTITY_INSERT blah
SET IDENTITY_INSERT blah
DELETE FROM blah
DELETE FROM blah
DELETE FROM blah
now I know I could write a simple python script to accomplish this quickly but I'm trying to up my VIM skills.
Upvotes: 6
Views: 446
Reputation: 9404
You can use g command:
:g/^DELETE/m$
This will move (m) all lines starting with DELETE to the end of the file ($).
Upvotes: 7
Reputation: 47311
the following does not use any regex...
:sort!
details : http://vim.wikia.com/wiki/Sort_lines
Upvotes: 1