When editing a C# source file, I type
编辑C#源文件时,我输入
new {
Visual Studio auto-corrects it to
Visual Studio自动更正它
new object{
Is there a way to stop this behavior?
有没有办法阻止这种行为?
5 个解决方案
#1
You can configure which characters being typed commit the current intellisense selection. In Tools | Options | Text Editor | C# | IntelliSense.
您可以配置要键入的字符提交当前的智能感知选择。在工具|选项|文字编辑器| C#|智能感知。
Remove "{" and ensure committed by the space bar is not checked.
删除“{”并确保未选中空格键提交的内容。
NB. This option is no longer present as of Visual Studio 2015.
NB。从Visual Studio 2015开始,此选项不再存在。
#2
I ran into this issue, and the answers above didn't work for me. In my case, it was caused by Resharper, and I addressed it by navigating to Resharper -> Options -> Environment -> Intellisense -> Completing Characters and adding the opening curly brace character "{" to the "Do not complete on" list for C#.
我遇到了这个问题,上面的答案对我不起作用。在我的情况下,它是由Resharper引起的,我通过导航到Resharper - >选项 - >环境 - >智能感知 - >完成字符并将开头大括号字符“{”添加到“不完整”列表来解决它对于C#。
#3
What are you typing before the new {
?
你在新{之前打字的是什么?
I've just tried it and it auto-completes with the object type, so if I type:
我刚尝试了它并且它使用对象类型自动完成,所以如果我输入:
Button test = new {
it becomes:
Button test = new Button{
But if I type:
但如果我输入:
var test = new {
it leaves it alone.
它让它独自一人。
I haven't configured my VS2008 install in any way.
我没有以任何方式配置我的VS2008安装。
#4
Have you checked your auto-complete options for ReSharper? I just tried this in a new (empty) class with the default ReSharper settings and couldn't duplicate it. What version of studio/ReSharper are you using?
你有没有检查过ReSharper的自动完成选项?我只是在一个新的(空)类中尝试使用默认的ReSharper设置,并且无法复制它。您使用的是什么版本的studio / ReSharper?
#5
Try typing the left brace first, then going back and typing new. VS2008 does this for me (without ReSharper) and, if I remember, this is what I do. It's less typing than deleting the inserted "object".
尝试先键入左括号,然后返回并键入新的。 VS2008为我做了这个(没有ReSharper),如果我记得的话,这就是我的工作。它比删除插入的“对象”更少打字。
#1
You can configure which characters being typed commit the current intellisense selection. In Tools | Options | Text Editor | C# | IntelliSense.
您可以配置要键入的字符提交当前的智能感知选择。在工具|选项|文字编辑器| C#|智能感知。
Remove "{" and ensure committed by the space bar is not checked.
删除“{”并确保未选中空格键提交的内容。
NB. This option is no longer present as of Visual Studio 2015.
NB。从Visual Studio 2015开始,此选项不再存在。
#2
I ran into this issue, and the answers above didn't work for me. In my case, it was caused by Resharper, and I addressed it by navigating to Resharper -> Options -> Environment -> Intellisense -> Completing Characters and adding the opening curly brace character "{" to the "Do not complete on" list for C#.
我遇到了这个问题,上面的答案对我不起作用。在我的情况下,它是由Resharper引起的,我通过导航到Resharper - >选项 - >环境 - >智能感知 - >完成字符并将开头大括号字符“{”添加到“不完整”列表来解决它对于C#。
#3
What are you typing before the new {
?
你在新{之前打字的是什么?
I've just tried it and it auto-completes with the object type, so if I type:
我刚尝试了它并且它使用对象类型自动完成,所以如果我输入:
Button test = new {
it becomes:
Button test = new Button{
But if I type:
但如果我输入:
var test = new {
it leaves it alone.
它让它独自一人。
I haven't configured my VS2008 install in any way.
我没有以任何方式配置我的VS2008安装。
#4
Have you checked your auto-complete options for ReSharper? I just tried this in a new (empty) class with the default ReSharper settings and couldn't duplicate it. What version of studio/ReSharper are you using?
你有没有检查过ReSharper的自动完成选项?我只是在一个新的(空)类中尝试使用默认的ReSharper设置,并且无法复制它。您使用的是什么版本的studio / ReSharper?
#5
Try typing the left brace first, then going back and typing new. VS2008 does this for me (without ReSharper) and, if I remember, this is what I do. It's less typing than deleting the inserted "object".
尝试先键入左括号,然后返回并键入新的。 VS2008为我做了这个(没有ReSharper),如果我记得的话,这就是我的工作。它比删除插入的“对象”更少打字。