Vim

Various snippets and things I frequently forget

JSON

JS to JSON

Copying a Javascript object out of code and into its own JSON file involves a painful process of quoting things. This snippet will wrap quotes around each key:

:%s/\zs[a-z]\+\ze:/"\0"/g

Format JSON

:%!python -m json.tool