Get word at caret position

I want to create a simple plugin that gets the word at the current caret position (similiar to what Ctrl+Shift+w does) and then searches the solution for files using that word.
I want it to work regardless of the file type currently open in the editor (*.cs, *.cshtml, *.js etc.).

I tried using ITextControl to get the current word, but couldn't find exactly what I needed.


1 comment
Comment actions Permalink

You should take a look at the FindText sample in the SDK. This will search for text usage, but requires you to type text into a dialog text box, rather than using the current selection. If you want to use the current selection, you can use ITextControl.Selection.Ranges to get the current selection (read the xml doc comments on that property for usage), and get the actual text with the ITextControl.GetTextInRange extension method.



Please sign in to leave a comment.