Last active
May 24, 2017 20:40
-
-
Save kennyp/29371c6257e477a25fd5e9e3b78183fd to your computer and use it in GitHub Desktop.
Format Expanded Postgres Output As YAML
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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