String colorization

In VS, you can have your strings colorized.  This feature has been around for a long time.  However, the default string color is the same as the default text color, so you may not notice at first.

In C#, there are two string colors: “String” and “Verbatim String”.  In Whidbey, I'm pushing to have both string colors be the same as each other, but different than other colors.  I also like to set the colors for “Number“ and “Operator“.  In the past, I've found this colorization very helpful in reading my code.

As I work at my OO skills, the significance of literal strings in my code has decreased, and all my code has become simpler, so maybe this is changing for me.

Comments (6)

  1. Jeff Clark says:

    I agree. When setting up VS I always change the string color so that strings are easier to see in the code, even if it's to just identify strings that should be in a resource somewhere.

  2. Jim Bolla says:

    agreed. the default string color should be different. me personally, i use red. the different color has the added benefit of making it quick to spot when you forgot a closing quote as code that shouldn't be red, now is.

  3. Travis says:

    Is there a good (simple) way to export VS color settings from one machine to another? It takes a lot of tweaking to get them just right 🙂

  4. jaybaz [MS] says:

    Travis: In Whidbey, you can use the Profiles feature to save & share settings.

    You can try saving out HKCUSWMSVS??FontsAndColor


    There are many cases where you have to use escaping: command line, javascript, html, C#, SQL, XML, regex,...

    Sometimes these embed in each other (if you have C# that spits out javascript for example).

    The code editor should have IntelliSense type tooltips for strings, to remove all doubt.

    Two problems:

    - how would the editor know that a string is escaped javascript escaped in C#? Maybe strings should be tagged with a "type".

    - some strings are built dynamically. Maybe a helper form could make it easy to try values by letting you provide the dynamic parts.

  6. Travis says:

    Thank you! That worked perfectly.

Skip to main content