I heard someone had set up their editor to highlight python raw strings as regular expressions, e.g. for Django:

urls(r'^site1/(\d)*/new$'', ...)

Unfortunately my googleing doesn't get me anything. Is this possible in vim?

  • I'm not sure to really see what you're trying to do but have you tried to put this line in your vimrc let python_highlight_all = 1? Also for enhanced python highlightinh see here – statox Aug 10 '15 at 13:14
  • 1
    What I meant was, the regular expression within the url function call up there should receive its own syntax highlighting, marking e.g. groupings in one colour, colour the parentheses, the asterisk, etc. Not just highlight it in one colour as a string (and maybe a second colour for "\n", "\r" etc.). python_highlight_all does nothing and I cannot find it in the help system. The linked enhanced python highlighting also doesn't do this. – yggdrasil Aug 10 '15 at 15:48
  • Ok, so I'd say that what you want is to extend the highlighting so maybe this link explaining how to create your own syntax file could help (basically it explains how to match some regex and color them the way you want). Otherwise sorry if that didn't help. – statox Aug 10 '15 at 16:00
  • Is the '' at the end of the string deliberate or a typo? I imaging this can be done, since Vim highlights regexes in Vimscript files. – muru Apr 9 '16 at 8:47

Your Answer

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

Browse other questions tagged or ask your own question.