Last active
August 29, 2015 13:57
-
-
Save richleland/9489438 to your computer and use it in GitHub Desktop.
How can I do a search and replace in vim that will replace everything between "this as that" and "from", regardless of the number of columns being selected in between?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select | |
this as that, | |
* | |
from | |
table_name | |
select | |
this as that, | |
* | |
from | |
table_name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# do this inside vim: | |
:%s/this as that,\_.\{-}from/this as that, *\rfrom/g |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select | |
this as that, | |
column1, | |
column2, | |
column3, | |
column4, | |
from | |
table_name | |
select | |
this as that, | |
column1 | |
from | |
table_name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment