Friday, November 15, 2013

Highlight the locking primitives in the C/C++ code

A quick hack to highlight the locking calls in a C/C++ program:

:syn match cTodo '\<\i*[lL]ock\i*\>'

Reuses colors of the "TODO" and "XXX" items.

Edit1 I like this one better:

function! LockSyntaxFix()
        :syn match WarningMsg '\c\i*\(un\)\@<!\(lock\)\i*'
        :syn match MoreMsg '\c\i*unlock\i*'

Red (WarningMsg) for lock, green (MoreMsg) for unlock. Trick is in the regexp which allows to match "lock" in all cases except "unlock". Packed into a function to be called when debugging locking.

No comments: