Sunday, September 30, 2012

Re: JSON file autoformat

Primus wrote:

> I often need to reformat json code.
>
> The problem I have is it always indent the first line of a hash
>
> e.g.
> [quote]
> "a" : {
> "b" : "c",
> "d" : "e"
> }
> [/quote]
>
> becomes
>
> [quote]
> "a" : {
> "b" : "c",
> "d" : "e"
> }
> [/quote]
>
> Is there any way to solve this problem?
>
> I am aware of the :%!python -m json.tool method, however it give my
> code a re-sorting, which I have to avoid.
>
> Any idea?
>
> Thanks for your advice!

The current Javascript indent plugin seems to do this right.
It's old, you probably have it, perhaps you use another file type?

--
"When I die, I want a tombstone that says "GAME OVER" - Ton Richters

/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: