Skip to content

Instantly share code, notes, and snippets.

@DamianSuess
Last active August 28, 2019 03:50
Show Gist options
  • Save DamianSuess/115ff647c0d1c11760fa5cb9b3fdc74e to your computer and use it in GitHub Desktop.
Save DamianSuess/115ff647c0d1c11760fa5cb9b3fdc74e to your computer and use it in GitHub Desktop.
C# AvalonEdit Comment Lines
TextDocument document = textEditor.Document;
DocumentLine start = document.GetLineByOffset(textEditor.SelectionStart);
DocumentLine end = document.GetLineByOffset(textEditor.SelectionStart + textEditor.SelectionLength);
using (document.RunUpdate()) {
  for (DocumentLine line = start; line != end; line = line.NextLine)
  {
    document.Insert(line.Offset, "// ");
  }
}

Reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment