Skip to content

Instantly share code, notes, and snippets.

@dialogbox
Created July 21, 2016 07:30
Show Gist options
  • Save dialogbox/038b9e3bdf303d030f7dd4a9cb1b03e7 to your computer and use it in GitHub Desktop.
Save dialogbox/038b9e3bdf303d030f7dd4a9cb1b03e7 to your computer and use it in GitHub Desktop.
Vim ex command to add type specifier to all string constant in PostgreSQL.
:%s/\('.\{-}'\)\(\s*\)\(::\)\@!/\1::text\2/g
@dialogbox
Copy link
Author

It converts select 'aaa'; to select 'aaa'::text;.

@dialogbox
Copy link
Author

:%s/\('\(''\|[^']\)*'\)\(\s*\)/\1::text\3/g

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment