like WORD completion shortcut in VisualStudio 2010?
I have recently switched from Java development and Eclipse IDE to C# .NET and VisualStudio 2010. What I really miss is the Alt + / Eclipse shortcut for word completion. I am NOT speaking about IntelliSense auto completion stuff. I mean, I would like the text editor to finish writing words that already exist somewhere in the document but will not show up in IntelliSense, eg string literals.
In Notepad++ it is the Ctrl + Enter shortcut. In Eclipse it is the aforementioned Alt + /
Can VS2010 do the same? If not by default, can anyone point me to a decent VB macro that I could plug into my VS2010 to do this?
Thank you.
EDIT
Please mind there is a difference between CODE completion (ie what in most IDEs/clever editors is performed by Ctrl+Space) and simple WORD completion (what I am looking for). Word completion does not try to analyse the current context, or guess what type/method you might be after. All it does it tries to complete a work you started typing by looking around your cursor location and searching for similar words already occurring in the current document.
I've created a simple VS macro:
Public Sub CompletePreviousWord()
Dim doc As EnvDTE.Document = DTE.ActiveDocument
Dim selection As TextSelection = doc.Selection
' word to left is what we want to find
selection.WordLeft(True, 1)
Dim findWord As String = selection.Text
' get search text from the beginning of the document
Dim ep As EditPoint = selection.ActivePoint.CreateEditPoint()
ep.StartOfDocument()
Dim searchText As String = ep.GetText(selection.ActivePoint)
Dim match = Regex.Match(searchText, "[^a-zA-Z0-9_]?(" + findWord + "[a-zA-Z0-9_]*)", _
RegexOptions.IgnoreCase Or RegexOptions.RightToLeft)
If match.Success Then
' replace the whole world - for case sensitive and to allow undo (by doing only one operation)
selection.Insert(match.Groups.Item(1).Value)
Else
selection.WordRight(False, 1)
End If
End Sub
Bounded it to alt-space and it does the trick for me.
Shlomi
Can VS2010 do the same?
No by default.
If not by default, can anyone point me to a decent VB macro that I could plug into my VS2010 to do this?
Don't know any that exists. But this could be a nice project to do.
In Visual Studio Code (VSC) there is an extension, "Another Word Completion" by getogrand. I know your question was regarding Visual Studio, but this may be of interest to others searching for this who wind up here.
Yup, hard to search for this since "code completion" term is more common.
链接地址: http://www.djcxy.com/p/47540.html