Skip to content

Instantly share code, notes, and snippets.

@kam1kaze
Last active April 11, 2018 12:07
Show Gist options
  • Save kam1kaze/66eb6694c907d6da1a4e480a965cd06f to your computer and use it in GitHub Desktop.
Save kam1kaze/66eb6694c907d6da1a4e480a965cd06f to your computer and use it in GitHub Desktop.
vim.md

VIM allows execute external commands and replace neccessary line/block with the command output.

  • :. - current line
  • :% - full buffer
  • :1,10 - line range
  • :'<,'> - visually selected block

Format JSON with jq

:.!jq .

XML:

:%!xmllint --format -

Example, parse and sort terraform JSON output:

:%s,\\",",g
:%!jq '.[].environment = ( .[].environment | sort_by(.name) )'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment