Line Separators in the VS Core Editor

During the VSIP Developer Lab that was held here in Redmond last week, I investigated a quick question for GrafX about how to put line separators in the editor. If you don't know what I mean, open up a Visual Basic project, and create a file with 2 VB classes defined in it. See the lines after the Imports statements and after class definitions?


Here's what you need to do to add those line separators to the VS editor. In the colorizer's ColorizeLine method, you need to set the SEPARATOR_AFTER_ATTR flag for the last character of the line. As an example of this, here is a colorizer implementation that I added to the RegExLanguageService sample which will add a separator line on any line with text (length>=1):

using System;
using Microsoft.VisualStudio.Package;
using Microsoft.VisualStudio.TextManager.Interop;

namespace Microsoft.Samples.VisualStudio.LanuageServices.RegularExpressionLanguageService
    class RegExColorizer : Colorizer
        public RegExColorizer(LanguageService svc, IVsTextLines buffer, IScanner scanner) : base(svc, buffer, scanner) { }
        public override int ColorizeLine(int line, int length, IntPtr ptr, int state, uint[] attrs)
            int baseReturnVal = base.ColorizeLine(line, length, ptr, state, attrs);
            if (attrs != null && length >= 1)
                    attrs[attrs.Length-1] |= (uint)COLORIZER_ATTRIBUTE.SEPARATOR_AFTER_ATTR;
            return baseReturnVal;


You can, of course, do this in a C++ based language service as well on your IColorizer implementation.


Comments (2)
  1. Ericga says:

    Even with that code example, we’ve never been able to make those line separators work in the C# editor. Is it possible to have a more complete example?

  2. Aaron Marten says:

    Hi Eric,

    Showing the separator lines is a function of the Colorizer which is a part of the language service. In the case above, this was for adding the needed functionality to a custom language service. I don’t believe that C# has an extensible language service/colorizer, and so you would need to provide your own custom C# language service to provide that functionality.

    If you’d like, please contact me via the contact links on this blog so we can take this offline.



Comments are closed.

Skip to main content