public void Execute(object parameter) { if (editor.SelectionLength == 0) { int wordStart = DocumentUtilitites.FindPrevWordStart(editor.Adapter.Document, editor.CaretOffset); if (wordStart > 0) { string word = editor.Adapter.Document.GetText(wordStart, editor.CaretOffset - wordStart); CodeSnippet snippet = SnippetManager.Instance.FindSnippet(Path.GetExtension(editor.Adapter.FileName), word); if (snippet != null) { snippet.TrackUsage("CustomTabCommand"); using (editor.Document.RunUpdate()) { editor.Adapter.Document.Remove(wordStart, editor.CaretOffset - wordStart); snippet.CreateAvalonEditSnippet(editor.Adapter).Insert(editor.TextArea); } return; } } } baseCommand.Execute(parameter); }