On Tue, Feb 20, 2007 at 02:08:31AM -0300, g b wrote: > On 2/19/07, Marc Weber <[EMAIL PROTECTED]> wrote: > >On Sat, Feb 17, 2007 at 09:57:57PM -0200, g b wrote: > >> Any way to indent json correctly on vim? > >> Obj = { > >> att1: 'val1', > >> att2: 'val2', > >> } > > > >I don't know. But it shouldn't be that hard to use folding on { > >} and > >set indentexpr to a function returning folding level... > >This might get close to what you want > > obj = { > att1:'bal', > att2:'asd', > > > This is the current indenting i get with vim7.0.35 > It puts two extra tabs after the first attribute. the main issue > is > not with the {}s. > > Gabriel
I was thinking of syn region myFold start="{" end="}" transparent fold syn sync fromstart set foldmethod=syntax set indentexpr=foldlevel(line('.')) but this does only work if you write it this way: obj = { att1:'bal', att2:'asd', } But its not so hard writing your own indenting function. Just use motion [{ again and again to find outer most { and count them. This is your indentation level. Wrap this into a function and assign this to indentexpr.. You can use getpos() to see wether cursor has changed. Marc