How to set up Syntastic to check JSON files

Assuming you’ve got Syntastic installed and operating…

  1. Edit your vimrc so vim recognises JSON files.

    ~/.vimrc
    autocmd BufNewFile,BufReadPost *.json set filetype=json
  2. Install the JSON linter:

    npm install -g jsonlint
  3. There’s no step three.


Actually, I wasn’t completely honest about step three. Setting filetype=json killed syntax highlighting for JSON files for me, so I installed elzr/vim-json. (Previously JSON was being detected and highlighted as Javascript – possibly via pangloss/vim-javascript; a “stock” vim on a different machine managed to detect and highlight JSON out-of-the-box.)

Comments