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.


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

Is it possible to fold JSON structure in Vim?

1 Answer 1


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

:set filetype=json
:syntax on
:set foldmethod=syntax
  • 2
    what keystroke needed to fold and unfold a section?
    – WitVault
    Dec 9, 2016 at 11:04
  • 8
    :h fold-commands - zo - open and zc - close
    – grodzik
    Dec 9, 2016 at 11:46
  • 9
    za - toggle fold
    – alecdwm
    Aug 12, 2019 at 7:26
  • FWIW: This isn't enabling folding for me. "E490: No fold found".
    – spazm
    Nov 3, 2020 at 20:40
  • 1
    @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, 2020 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.