In vim, the default indentation for JSON is:
{
"employees": [
{ "firstName":"John" , "lastName":"Doe" },
{ "firstName":"Anna" , "lastName":"Smith" },
{ "firstName":"Peter" , "lastName":"Jones" }
]
}
But what I expect is:
{
"employees": [
{ "firstName":"John" , "lastName":"Doe" },
{ "firstName":"Anna" , "lastName":"Smith" },
{ "firstName":"Peter" , "lastName":"Jones" }
]
}
I did google and tried some vim-json plugins, but none of them fix this issue.
python -m json.tool
reorders the position of the JSON object properties, if you have node installed, you can just use this function:Mapped to
f-j
in .vimrcYou can also pass a number of spaces for a tab, 2 are the default if you don't specify any.
My complete .vimrc is here https://github.com/botverse/.dotfiles/blob/master/.vimrc