" pg_apprentice's vim shortcuts - paste at end of .vimrc " This function is needed for what follows: " from :help abbreviations, then /consume the space func Eatchar(pat) let b = nr2char(getchar()) return (b =~ a:pat) ? '' : b endfunc " This sets us up with a nice CREATE TABLE with parentheses iab ct CREATE TABLE( xi);kkkA " This sets us up with a nice table level primary key constraint, labeling the constraint " table_name_pkey by searching backwords for the first CREATE TABLE statement iab cpk CONSTRAINT mp?CREATE TABLE2wye`ppa_pkey PRIMARY KEY():silent nohA=Eatchar('\s') " This sets up column level foreign key constraints by searching through your file and grabbing " whatever is set up as column_name .*PRIMARY.*KEY, and also grabbing the associated table name " for that column. iab rf REFERENCES mp^?.*PRIMARY.*KEY?CREATE TABLE2wye`ppa(:silent nohmp^ye`ppa),