visual-studio 无论如何禁用对象关键字的Visual Studio自动完成
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1022219/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is there anyway to disable Visual Studio auto complete for object keyword
提问by RichardOD
Short version- is there a way to turn off Visual Studio Intellisense for the object keyword.
简短版本 - 有没有办法为 object 关键字关闭 Visual Studio Intellisense。
Long version- I'm using Visual Studio 2008 and I'm basically using anonymous types. I begin typing something like:
长版 - 我使用的是 Visual Studio 2008 并且我基本上使用匿名类型。我开始输入以下内容:
Assert.AreEqual("/SomePath/Stuff", GetOutboundUrl(
I type in new {
我输入 new {
Then I see that Visual Studio has recognised that the method GetOutboundUrltakes an object and changed the code to new object{. Now must of the time this is great, except for two reasons:
然后我看到 Visual Studio 已经识别出该方法GetOutboundUrl接受一个对象并将代码更改为new object{. 现在必须的时候这很好,除了两个原因:
1) I rarely have code that uses the type object.
1)我很少有使用类型对象的代码。
2) I am actually trying to create an anonymous type not a object, so this feature is actually serving as a hindrance.
2)我实际上是在尝试创建一个匿名类型而不是一个对象,所以这个功能实际上是一个障碍。
The signature for GetOutboundUrl is as follows (from the book Pro ASP.NET MVC framework if anyone is interested):
GetOutboundUrl 的签名如下(如果有人感兴趣,可以从 Pro ASP.NET MVC framework 一书中找到):
private string GetOutboundUrl(object routeValues)
I am wondering if there is a way to turn this feature off but only for the keyword object- I would like to see if I actually miss the autocomplete on object (personally I don't think that I will).
我想知道是否有办法关闭此功能,但仅适用于关键字对象 - 我想看看我是否真的错过了对象的自动完成功能(我个人认为我不会)。
I realise that I can turn this off for all keywords by unchecking "Place keywords in completion lists", but I only want to turn it off for object.
我意识到我可以通过取消选中“在完成列表中放置关键字”来为所有关键字关闭此功能,但我只想为对象关闭它。
回答by John Fisher
Without changing an actual Visual Studio setting (which I doubt exists), you could type "new ", then ESC, followed by "{". It's not ideal, but it keeps you from having to delete the word "object" each time.
无需更改实际的 Visual Studio 设置(我怀疑是否存在),您可以键入“new”,然后是 ESC,然后是“{”。这并不理想,但它使您不必每次都删除“对象”一词。
You could address this particular situation by editing the options: "Text Editor" -> "C#" -> "IntelliSense" => "Committed by typing the following characters:". Remove the "{".
您可以通过编辑选项来解决这种特殊情况:“文本编辑器”->“C#”->“智能感知”=>“通过键入以下字符提交:”。除掉 ”{”。
回答by Lance Fisher
I made a ReSharper Live template:
我制作了一个 ReSharper Live 模板:
Shortcut: new
Contents:
new { $END$ }
Now I can type n-e-w-TAB and I end up with "new { }" and my cursor between the curlies.
现在我可以输入 new-TAB 并以“new { }”和我的光标在卷曲之间结束。
It's not ideal, but it's better.
这并不理想,但它更好。
回答by Raghav
To turn IntelliSense options OFF by default
默认情况下关闭 IntelliSense 选项
On the Tools menu, click Options.
在工具菜单上,单击选项。
Select the Text Editor folder.
选择文本编辑器文件夹。
Select the folder for the language you want to customize IntelliSense.
选择要自定义 IntelliSense 的语言的文件夹。
In the General property page, clear check boxes for IntelliSense features that you do not want:
在“常规”属性页中,清除不需要的 IntelliSense 功能的复选框:
Auto list members applies to List Members
Parameter information applies to Parameter Info
回答by Raghav
What I do when intellisense gets annoying is comment out a few blank lines, write my code on those lines, as comments, then uncomment them when I'm through. Voila, you can write whatever you want and intellisense will not butt in. Other times, when you want intellisense, it's not disabled. I hope this helps someone out there!
当智能感知变得烦人时,我所做的是注释掉几行空行,在这些行上写下我的代码作为注释,然后在我完成时取消注释。瞧,你可以写任何你想要的东西,智能感知不会插入。其他时候,当你想要智能感知时,它不会被禁用。我希望这可以帮助那里的人!

