Skip to content

Instantly share code, notes, and snippets.

@achiku
Last active February 27, 2018 07:46
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 achiku/c1832e59ba8cb033d481891cbd1865d6 to your computer and use it in GitHub Desktop.
Save achiku/c1832e59ba8cb033d481891cbd1865d6 to your computer and use it in GitHub Desktop.
sqlformat.vim
"" sqlfmt
let g:sqlfmt_command = "sqlformat"
let g:sqlfmt_options = "-r -k lower --comma_first True -"
function! SQLfmtv() range
let tmp = @@
silent normal gvy
let selected = @@
let @@ = tmp
let cmd = printf("%s %s << SQL\n%s\nSQL", g:sqlfmt_command, g:sqlfmt_options, selected)
echo cmd
let lines = system(cmd)
echo lines
endfunction
command! -range SQLfmtv :call SQLfmtv()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment