VisualStudio 2010 中有类似 Eclipse 的 WORD 补全快捷方式吗?

发布于 2024-09-14 13:39:23 字数 629 浏览 3 评论 0原文

我最近从 Java 开发和 Eclipse IDE 切换到 C# .NET 和 VisualStudio 2010。我真正怀念的是用于单词完成的 Alt + / Eclipse 快捷方式。我不是在谈论 IntelliSense 自动完成的东西。我的意思是,我希望文本编辑器完成编写文档中某处已存在但不会显示在 IntelliSense 中的单词,例如字符串文字。

在 Notepad++ 中,它是 Ctrl + Enter 快捷键。 在 Eclipse 中是前面提到的 Alt + /

VS2010 可以做同样的事情吗?如果不是默认情况下,任何人都可以向我指出一个不错的 VB 宏,我可以将其插入到 VS2010 中来执行此操作吗?

谢谢。

编辑

请注意代码完成(即在大多数IDE/聪明的编辑器中由Ctrl+空格执行)和简单的WORD之间存在差异完成(我正在寻找的)。单词完成不会尝试分析当前上下文,或猜测您可能需要什么类型/方法。它所做的一切都是试图通过环顾光标位置并搜索当前文档中已经出现的相似单词来完成您开始输入的工作。

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, e.g. 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 (i.e. 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

誰ツ都不明白 2024-09-21 13:39:23

我创建了一个简单的 VS 宏:

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

将其限制为 alt-space,它对我有用。

什洛米

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

一影成城 2024-09-21 13:39:23

VS2010 可以做同样的事情吗?

默认情况下不可以。

如果不是默认情况下,任何人都可以向我指出一个不错的 VB 宏,我可以将其插入到 VS2010 中来执行此操作吗?

不知道是否存在任何宏。但这可能是一个不错的项目。

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.

呆萌少年 2024-09-21 13:39:23

在 Visual Studio Code (VSC) 中,有一个由 getogrand 提供的扩展“Another Word Completion”。我知道您的问题是关于 Visual Studio 的,但这可能会让其他搜索此内容并最终来到这里的人感兴趣。

是的,很难搜索这个,因为“代码完成”术语更常见。

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.

祁梦 2024-09-21 13:39:23

VS2010默认有这个功能:

快捷键:“ALT + 向右键”或“CTRL + 空格键”

工具栏按钮:(由于我是新用户,请手动打开截图图片 https://i.sstatic.net/OyiHY.png)

相关命令对象名称:Edit.CompleteWord(参见:http://msdn.microsoft.com/en-us/library/xte2hh6a %28v=vs.71%29.aspx

顺便说一句,我使用的是 VS2010 专业版。

VS2010 has that feature by default:

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

Toolbar button: (as I'm a new user, please open the screenshot picture manually at https://i.sstatic.net/OyiHY.png)

Relevant Command Object Name: Edit.CompleteWord (see: http://msdn.microsoft.com/en-us/library/xte2hh6a%28v=vs.71%29.aspx )

BTW, I'm using VS2010 professional.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文