33

I have a large JSON file. It is not easy to work on all file at a time. I want to fold some content so that I can work on a section of JSON file.

E.g.:

{
  obj: {+}, // folded section
  obj:{
        // unfolded section
     }
}

Is it possible to fold JSON structure in Vim?

44

Yes, it is possible. A minimal setup would be:

:set filetype=json
:syntax on
:set foldmethod=syntax
| improve this answer | |
  • 1
    what keystroke needed to fold and unfold a section? – WitVault Dec 9 '16 at 11:04
  • 7
    :h fold-commands - zo - open and zc - close – grodzik Dec 9 '16 at 11:46
  • 5
    za - toggle fold – alecdwm Aug 12 '19 at 7:26
  • FWIW: This isn't enabling folding for me. "E490: No fold found". – spazm Nov 3 at 20:40
  • @spazm: So you can probably ask a new question here, describe what OS you're using, what exact editor, what version, all the steps you're doing, all the info that could be helpful. – grodzik Nov 5 at 12:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.