Other files, like .c, .cpp, .java, etc., I like to indent 4 spaces, but with only .json files, I like to indent 2 spaces.

How can I configure vim for this purpose?

I know it's possible to do :!%jq . to format the entire json file, but what I want is the automatic indentation set specifically for the json file instead of manually entering instructions to format the file.

  • See :help ftplugin.
    – romainl
    Jan 20 at 14:42


Your Answer

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

Browse other questions tagged or ask your own question.