protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) { DocumentView docView = await VS.Documents.GetActiveDocumentViewAsync(); NormalizedSnapshotSpanCollection selections = docView.TextView?.Selection.SelectedSpans; if (selections == null) { return; } using (ITextEdit edit = docView.TextBuffer.CreateEdit()) { var guid = Guid.NewGuid().ToString(); foreach (SnapshotSpan selection in selections.Reverse()) { edit.Replace(selection, guid); } edit.Apply(); } }