Skip to content

Instantly share code, notes, and snippets.

@kennyp
Last active May 24, 2017 20:40
Show Gist options
  • Save kennyp/29371c6257e477a25fd5e9e3b78183fd to your computer and use it in GitHub Desktop.
Save kennyp/29371c6257e477a25fd5e9e3b78183fd to your computer and use it in GitHub Desktop.
Format Expanded Postgres Output As YAML
function! ExpandedToYaml()
'<,'>s/ t$/ true/e
'<,'>s/ f$/ false/e
'<,'>g!/| \(true\|false\|[0-9\.]*\)$/s/| \(.*\)/| "\1"/
'<,'>s/[^ ]*\zs[ ]*|/:/e
'<,'>s/^/ /
'<,'>g/:$/d
endfun
vmap <silent> <Leader>c :<C-U>call ExpandedToYaml()<cr><cr>
nmap <silent> <Leader>c :set paste<cr>"+p:set nopaste<cr>`[v`]:<C-U>call ExpandedToYaml()<cr><cr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment