简体   繁体   English

如何使用 Visual Studio + ReSharper 禁用不需要的自动完成功能?

[英]How to disable undesirable auto-complete with Visual Studio + ReSharper?

I'm using Visual Studio 2010 and ReSharper 5.我正在使用 Visual Studio 2010 和 ReSharper 5。

I define this at the top of a .cs file.我在 .cs 文件的顶部定义了它。

#if X86
using size_t = System.Int32;
#else
using size_t = System.Int64;
#endif

Then I can use size_t and know that it is a native integer, 32 bits if compiled as a 32 bit assembly, and 64 bits if compiled as a 64 bit assembly.然后我可以使用 size_t 并知道它是一个本机整数,如果编译为 32 位程序集,则为 32 位,如果编译为 64 位程序集,则为 64 位。 (for those that are curious, the alternatives are always use Int64, or branch at runtime on IntPtr.Size == 4 and have two versions of the code. I prefer this solution.) (对于那些好奇的人,替代方案总是使用 Int64,或者在运行时在 IntPtr.Size == 4 上分支并且有两个版本的代码。我更喜欢这个解决方案。)

However, if I type size_t and hit space, it will be automatically converted to Int64 (or Int32 if X86 is defined).但是,如果我输入 size_t 并点击空格,它将自动转换为 Int64(如果定义了 X86,则为 Int32)。 Obviously that's undesirable.显然这是不可取的。

I went into ReSharper options and went to Environment \\ Intellisence \\ Completion behavior and disabled all the checkboxes under "Automatically complete single item with:".我进入 ReSharper 选项并进入 Environment \\ Intellisence \\ Completion behavior 并禁用“自动完成单个项目:”下的所有复选框。

It still happens, is there anything else I can try?它仍然发生,还有什么我可以尝试的吗?

I ran into a similar issue (using VS2013 and Resharper 8.2).我遇到了类似的问题(使用 VS2013 和 Resharper 8.2)。

To stop the undesirable auto-completion on every "space" hit, I had to disable IntelliSense completion on "space" both within VS and R# options:为了在每次“空格”命中时停止不需要的自动完成,我必须在 VS 和 R# 选项中禁用对“空格”的 IntelliSense 完成:

  1. VS > Tools > Options > Text Editor > C# > IntelliSense > "Committed by pressing the space bar" checkbox VS > 工具 > 选项 > 文本编辑器 > C# > IntelliSense >“按空格键提交”复选框
  2. VS > Resharper > Options > Environment > IntelliSense > Completing Characters > C# "Complete on space" checkbox VS > Resharper > Options > Environment > IntelliSense > Completing Characters > C#“Complete on space”复选框

Cheers!干杯!

One solution would be to toggle to suggestion completion mode for intellisense.一种解决方案是切换到智能感知的建议完成模式。 The default key binding for the toggle is Ctrl+Alt+Space .切换的默认键绑定是Ctrl+Alt+Space When in suggestion mode, it will only change what you type if you explicitly choose a value to change to.在建议模式下,如果您明确选择要更改的值,它只会更改您键入的内容。 You can read more about it here:你可以在这里读更多关于它的内容:

http://blogs.msdn.com/b/zainnab/archive/2012/05/01/9943045.aspx http://blogs.msdn.com/b/zainnab/archive/2012/05/01/9943045.aspx

In the VS2017 menu hierarchy the suggestion mode can be found under:在 VS2017 菜单层次结构中,可以在以下位置找到建议模式:

Edit -> Intellisense -> Toggle Completion Mode

Additionally when the suggestion mode is enabled, it is visually indicated by the following button (and can also be enabled/disabled by clicking the button):此外,当启用建议模式时,它会通过以下按钮直观地指示(也可以通过单击按钮启用/禁用):

Visual Studio 2017 建议模式按钮

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参数信息适用于Parameter Info

您可以使用转义键取消当前的智能感知建议。

In VS 2019 and ReSharper 2020 toggling completion mode doesn't solve the issue - suggestions are applied when spacebar is hit.在 VS 2019 和 ReSharper 2020 中,切换完成模式无法解决问题 - 按下空格键时会应用建议。 To have it working one has to go to:要让它工作,必须去:

Extensions -> ReSharper -> Options... -> IntelliSense -> Completing Characters

and uncheck Complete on space for a respective programming language并取消选中相应编程语言的Complete on space

ReSharper IntelliSense 设置

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM