Search code examples
javascriptsyntax-highlightingvim-syntax-highlighting

Is there a way to get syntax highlighting that highlights global and local variables differently in JavaScript?


Common workflows for me involve taking functions and breaking them apart into multiple functions, taking code that was not in a function and putting it in a function, and/or switching local variables to global variables for access by other functions or other code. This would be faster for me if I had a syntax highlighter that can highlight global variables and local variables differently. Does anyone know an easy way to do this, or can anyone recommend a syntax highlighter for which the code might be easy to modify for this purpose?

I am happy using any editor for this purpose.


Solution

  • Going by your tag it looks like you're using vim, in which case you can try the TagHighlight plugin, which supports Javascript. It adds a bunch of keywords types like GlobalVariable.