visual-studio-2010visual-studio-2005highlighting

Is there any way to 'highlight' code?


I'm currently using Visual Studio 2010 (and also have a copy of Visual Studio 2005 which I'm also happy to use if the functionality is available in it but not '10)

What I'm wondering is if there is any way to highlight pieces of code?

For instance, I'm currently working on an assignment to take a piece of code, and change the stack implementation. It would be really useful if I could highlight the stack implementation specific pieces of code so that it's easy for me to just glance at the screen and know which pieces need my attention rather than having to visually wade through it.

(I am using comments to highlight the stack implementation specific code - but they get a little lost amidst other comments - and this seems like a better idea.)


Solution

  • Consider using #region and #endregion blocks.

    From MSDN:

    #region lets you specify a block of code that you can expand or collapse when using the outlining feature of the Visual Studio Code Editor. In longer code files, it is convenient to be able to collapse or hide one or more regions so that you can focus on the part of the file that you are currently working on. The following example shows how to define a region:

    #region MyClass definition
    public class MyClass 
    {
        static void Main() 
        {
        }
    }
    #endregion
    

    For smaller sections / individual lines of code a quick way to jump between or keep track of them is to use Bookmarks. These can be added by using Ctrl+K, Ctrl+K and you can press Ctrl+K, Ctrl+N to move to the next bookmark, or Ctrl+K, CTRL+P for the previous bookmark. The Navigating Bookmarks article is a good quick reference.