1

I want to highlight breakpoint() - including brackets as keywords in Python files.

I have added these two commands to my .vimrc:

highlight link PyBreakpoint Keyword        
call matchadd("PyBreakpoint", '\<breakpoint\(\)\>')

However, only the breakpoint word gets matched and highlighted. How could I match the brackets also in order to apply the color to them also?

1
  • 1
    I think by default \( creates groups. Try :help pattern. Also, you might want to use after/syntax/python.vim and the syntax machinery; matches are somewhat limited – D. Ben Knoble Mar 2 at 14:58
1

Try removing the backslashes from the parens. This is what works for me.

call matchadd("PyBreakpoint", 'breakpoint()')

with example file:

this
that
breakpoint()
other
another  
1
  • 1
    I have ended up using call matchadd("PyBreakpoint", '\sbreakpoint()\s'). – niekas Mar 2 at 18:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.