Customization of Jeroen Ruigrok van der Werven's vim-json highlighting script. Pathogen-friendly.
- Added distinct highlighting for keywords! (This is what made me start this plugin.)
- Added syntax highlighting warning for decimals smaller than 1 that don't start with a 0 (so .1 gives a warning, it should be 0.1).
- Added syntax highlighting warning for comments and semicolons.
- Added folding of
{...}
and[...]
blocks. To enable it:setlocal foldmethod=syntax
(do it permanently on theftplugin/json.vim
file). - Added concealing of double quotes, for a minimalist CoffeScript-inspired look.
- This requires Vim 7.3+. To disable it
:setlocal conceallevel=0
(do it permanently on theftplugin/json.vim
file).
- This requires Vim 7.3+. To disable it
No syntax coloring: wall of text.
Javascript (or for that matter, json.vim) syntax coloring: Not much improvement from no syntax coloring.
Better JSON syntax coloring: a more meaningful, distinct and elegant presentation.
Here's 2 compelling reasons:
-
All JSON is Javascript but NOT all Javascript is JSON. So
{property:1}
is invalid becauseproperty
does not have double quotes around it.{'property':1}
is also invalid, because it's single quoted while the only thing that can placate JSON is double quoting. JSON is even fuzzy enough that{"property":.1}
is invalid, because you should have of course written{"property":0.1}
. Also, don't even think about having comments or semicolons, you guessed it: they're invalid. The point being that your syntax highlighter should warn you about these errors, in realtime, which is something that the Javascript highlighter doesn't (because in Javacript they're not errors!). -
Distinct highlighting for keywords. JSON is an extremely lightweight data format but at it's core lies an inescapable conceptual distinction: there are keywords and then there are values. There's nothing much to the format besides that, so we might as well display keywords and values differently. This is something that gets lost with Javascript-inspired syntax highlighters, which see keywords as just another string since JSON requires them double quoted. . JSON files become an impenetrable, indistinct wall of text.