Is there an Eclipse-style WORD completion shortcut in VisualStudio 2010?

I recently switched from Java and Eclipse IDE development to C # .NET and VisualStudio 2010. What I really missed is the Alt + / Eclipse shortcut to complete the word. I am NOT saying that IntelliSense uses autocomplete. I want to say that a text editor should finish writing words that already exist somewhere in the document, but will not be displayed in IntelliSense, for example. string literals.

In Notepad ++, this is the shortcut Ctrl + Enter . In Eclipse, this is the aforementioned Alt + /

Can VS2010 do the same? If not by default, can someone point me to a decent VB macro that I could connect to VS2010 to do this?

Thanks.

EDIT

Note that there is a difference between completing CODE (that is, that in most IDEs / smart editors it is done using Ctrl + Space) and simply ending WORD (which I'm searching for). Word completion does not try to analyze the current context or guess which type / method you could after. Everything that he does is trying to complete the work that you started typing by looking at the location of the cursor and looking for similar words that already appear in the current document.

+7
eclipse visual-studio keyboard-shortcuts
source share
4 answers

I 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 

Restricted it to alt-space, and it does the trick for me.

Shlomi

+3
source share

Can VS2010 do the same?

No by default.

If not by default, can someone point me to a decent VB macro that I could connect to VS2010 to do this?

I don’t know what exists. But it can be a good project.

+2
source share

Visual Studio Code (VSC) has the extension "Another Word Termination" using getogrand. I know that your question was about Visual Studio, but it may be of interest to others who are looking for this, who gets here.

Yup, it's hard to find this because the term "code completion" is more common.

0
source share

VS2010 has this feature by default:

Labels: "ALT + RIGHT ARROW" or "CTRL + SPACEBAR"

Toolbar button: (since I'm a new user, open the screenshot manually http://i.stack.imgur.com/OyiHY.png )

The corresponding command object name is: Edit.CompleteWord (see http://msdn.microsoft.com/en-us/library/xte2hh6a%28v=vs.71%29.aspx )

By the way, I'm using a professional VS2010.

-one
source share

All Articles