3

In Source Insight, global variable show up in a different colour. Is there a way to accomplish this in vi (or any other free editor)?

hojusaram
  • 133

2 Answers2

3

To do this the editor would need to be context aware (ie understand the syntax of the language) this requires the editor to be integrated with the compiler.

So though vim can do syntax highlighting of a very complex nature. This type of functionality is beyond it (well knowing how vim can be hacked I am sure somebody will now come and show how it is done, but it will not be trivial).

Vim's syntax highlighting falls into three categories:

  • Keywords
  • Matches (basically regular expressions)
  • Regions (A start regular expression and end regular expression)

About the only editor that is probably capable of this (and I am not sure it is). Is the one built into "Visual Studio 2010" (Though some emacs guru is going to come and say otherwise).

Loki Astari
  • 11,190
2

It may not be quite what you want, but you could have a look at my TagHighlight plugin for Vim.

Assuming your chosen language is supported by it (or at least by ctags: it's quite easy to add new languages), this plugin will use ctags to parse your source tree and identify a lot of extra keyword types (including global variables, which will be highlighted in the GlobalVariable style, so you'll need to define this if your colour scheme doesn't do so already).

DrAl
  • 443
  • 1
  • 3
  • 12