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.
You can use g command:
:g/^DELETE/m$
This will move (m) all lines starting with DELETE to the end of the file ($).
the following does not use any regex...
:sort!
details : http://vim.wikia.com/wiki/Sort_lines
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With