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.