There is no built-in way to highlight elements without using a tag shortcut. If you want to simply highlight specific names (instead of having a relatively slow response to the full tag label), you can change the tag label only to highlight specific names.
If you use my tag shortcut , you can change mktypes.py (if you are not using an executable version of Windows, in which case, write to me at the address on the website and I will compile it for you) by changing this:
UsedTypes = [ 'ctags_c', 'ctags_d', 'ctags_e', 'ctags_f', 'ctags_g', 'ctags_k', 'ctags_m', 'ctags_p', 'ctags_s', 'ctags_t', 'ctags_u', 'ctags_v' ]
:
UsedTypes = ['ctags_d']
This will lead to the creation of a type highlight file that includes only certain names, and therefore it should start much faster. If you have too many specific names in your project, it will slow down Vim anyway.
To highlight only specific names defined in the current file, add an autorun that calls the Vim function after reading the file. The function should be something like this:
function! HighlightDefinedNames() " Clear any existing defined names syn clear DefinedName " Run through the whole file for l in getline('1','$') " Look for #define if l =~ '^\s*#\s*define\s\+' " Find the name part of the #define let name = substitute(l, '^\s*#\s*define\s\+\(\k\+\).*$', '\1', '') " Highlight it as DefinedName exe 'syn keyword DefinedName ' . name endif endfor endfunction
You need to make sure that you highlight DefinedName in your color scheme, for example.
hi DefinedName guifg=
(assuming you are using a GUI).
DrAl Oct 03 '09 at 9:32 2009-10-03 09:32
source share