Sublime Forum

"%" is a valid string

#1

Can you help me to change the .cpp syntax highlighting? I don’t want it to make the background of the % red. And I don’t understand why “% some text %” and “%c” are treated like valid, and even “%” is not.

?? :slightly_smiling:

Thanks!

0 Likes

#2

Might want to file an issue here https://github.com/sublimehq/Packages/issues

0 Likes

#3

I don’t think any of these are wrong ( http://www.cplusplus.com/reference/cstdio/printf/ )

  • % is a special character and is not supposed to be used alone. You can escape it with %% not %
  • %c is correct, it is the format for a character.
  • “% s” is also correct since % can be followed by a space.
1 Like

#4

Yes sorry, %% not %, I was confused. But when you paste the code from e.g. http://www.cplusplus.com/reference/ctime/strftime/ ST doesn’t understand these format specifiers, I’d rather like it to be quiet about the %.

Oh and cout << “50%”; should just look valid. So the ST %-alarming is: 1) incomplete, see strftime 2) misplaced in C++

0 Likes