17

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?

27

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

:set filetype=json
:syntax on
:set foldmethod=syntax
  • what keystroke needed to fold and unfold a section? – WitVault Dec 9 '16 at 11:04
  • 1
    :h fold-commands - zo - open and zc - close – grodzik Dec 9 '16 at 11:46

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.