Skip to content

Instantly share code, notes, and snippets.

@richleland
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richleland/9489438 to your computer and use it in GitHub Desktop.
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?
select
this as that,
*
from
table_name
select
this as that,
*
from
table_name
# do this inside vim:
:%s/this as that,\_.\{-}from/this as that, *\rfrom/g
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