Vim syntax highlighting for C++11 raw strings
A little over a year ago I mentioned a vim syntax file for C++0x which I was using for a while, but it only adds support for some new keywords, not new syntax such as lambda expressions and list-initialization. Last month I found cpp11.vim in the Vim online script database, which intends to support the new C++11 syntax, by replacing your existing cpp.vim entirely.
Not quite satisfied with either of those, I've started using my own cpp.vim to extend the default cpp.vim file (which is done by putting it in ~/.vim/after/syntax/cpp.vim) with syntax highlighting for the new keywords and also C++11 raw strings.
With my colour settings they look like this:
which is equivalent to:
char raw = R"#(s/"\([^"]*\)"/'\1'/g)#";
only without suffering from leaning toothpick syndrome.
char yuk = "s/\"\\([^\"]*\\\"/'\\1'/g";
#in the example can be (almost) any sequence of zero or more characters acting as a delimiter. The example above requires a non-empty delimiter because the string contains
)", which would be taken as the end of the raw string otherwise:
char raw = R"(s/"\([^"]*\)"/'\1'/g)"; // ERROR!
You could choose to use
""as the delimiter sequence, as a nod to Python
char raw = R"""(triple-quoted for great justice)""";