如何在Visual Studio Code的注释中禁用IntelliSense?

如何在Visual Studio Code的注释中禁用IntelliSense?

问题描述:

我使用的是Visual Studio Code,主要用于PHP.每当我按下.时,IntelliSense就会启动并为我提供PHP全局变量和函数(从$_COOKIE开始).我通常知道我想要什么全局或函数,所以有点烦人.当我在注释块(/* ... */// ...)中时,甚至会发生这种情况,这更令人讨厌.我大部分时间都花在回溯和删除$_COOKIE上.

I'm using Visual Studio Code, mostly to work with PHP. Everytime I hit ., IntelliSense kicks in and offers me PHP globals and functions, starting with $_COOKIE. I usually know what global or function I want, so it's a bit annoying. This even happens when I'm within a comment block (/* ... */ or // ...), which is far more annoying. Most of my time is spent going back and deleting $_COOKIE.

一个示例(不是PHP,但您可以理解):

An example (not PHP, but you get the idea):

我尝试按照文档中的建议将其禁用:

I've tried disabling it as suggested in the docs:

// Controls if quick suggestions should show up while typing
"editor.quickSuggestions": false,

// Controls if suggestions should be accepted with "Enter" - in addition to "Tab". Helps to avoid ambiguity between inserting new lines and accepting suggestions.
"editor.acceptSuggestionOnEnter": true,

// Controls the delay in ms after which quick suggestions will show up.
"editor.quickSuggestionsDelay": 10000,

// Enable word based suggestions
"editor.wordBasedSuggestions": true

...但这绝对没有任何作用.当我碰到点时,我仍然会得到列表.从1001000的延迟增加也没有作用.

... but this has absolutely no effect whatsoever. I still get the list when I hit the dot. The delay increase from 100 to 1000, too, has no effect.

  1. 如何关闭代码注释中的IntelliSense?
  2. 如何在按.时禁用IntelliSense,并在按 Ctrl + Space 时显示它? (请参阅下面的更新2)
  3. 如何至少在PHP中完全禁用IntelliSense?
  1. How do I turn off IntelliSense inside code comments?
  2. How do I disable IntelliSense on hitting . and just have it show up when I hit Ctrl+Space? (See update 2 below)
  3. How do I disable IntelliSense completely, at least for PHP?

更新:如前所述

Update: As mentioned here, disabling quick suggestions on trigger characters is achieved via:

// Controls if suggestions should automatically show up when typing trigger characters
"editor.suggestOnTriggerCharacters": false

但是,上面提到的其他选项仍然无济于事.

However, the other options mentioned above still don't do anything.

更新2:这是可能会通过将其添加到keybindings.json文件中来弄乱.绑定:

Update 2: It is possible to mess with the . binding by adding this to the keybindings.json file:

{
    "key": ".",
    "command": "x",
}

但是,这会在屏幕顶部显示一条警告消息,提示找不到命令'x'".如果您将其保留为空或尝试将null传递给command,则它仍然不起作用,因为它不会覆盖默认的键绑定.根据文档,可以通过在-前面加上前缀来禁用某些操作,但这对我不起作用:

However,this results in a warning message at the top of the screen that says "command 'x' not found". If you leave it empty or try to pass null to command, it still doesn't work, as it doesn't overwrite the default key binding. According to the documentation, it's possible to disable a certain action by prefixing it with a -, but this doesn't work for me:

"command": "-^acceptSelectedSuggestion"

"command": "-acceptSelectedSuggestion"

无论哪种情况,当我按下时,acceptSelectedSuggesdtion并不是真正要执行的命令.,它可能更像是:

In either case, acceptSelectedSuggesdtion isn't really the command that's being executed when I hit ., it's probably more like:

"command": "-editor.action.triggerSuggest"

但这也不起作用.

自2017年3月或4月左右以来,此问题已得到修复,默认值已更改为注释中没有自动完成的内容.默认值为:

Since about March or April 2017, this has been fixed, and also the default has changed to be no auto-complete in comments. The default is:

"editor.quickSuggestions": {
  "other": true,
  "comments": false,
  "strings": false
},

我的设置中没有显式的内容,只是对一个新的PHP文件进行了测试,可以键入global.然后输入空格,并且不会自动完成任何操作. (我尝试了主代码和注释.)我确实看到$COOKIE作为第一个建议弹出,但是我需要使用向上/向下箭头,然后输入以将其引入.

I don't have that explicitly in my settings, and just did a test with a fresh PHP file, and I can type global. then space, and don't get anything auto-completed. (I tried both main code and in comments.) I do see $COOKIE pop up as the first suggestion, but I need to use up/down arrows and then enter to bring it in.

啊哈,global.,然后ENTER确实给了我global.$COOKIE(即使在注释中,这也有点不可思议).我可以通过以下方式解决此问题:

Aha, global. then ENTER does give me global.$COOKIE (even in comments, which is a bit weird). I can fix that with:

"editor.acceptSuggestionOnEnter": "off",

要查看您可能要触摸的其他设置,请转到设置页面,然后在搜索框中输入建议".每个评论.例如. "editor.suggestOnTriggerCharacters": false,完全摆脱了自动建议.

To see other settings you might want to touch, go to the settings page and type "suggestion" in the search box. Each is commented. E.g. "editor.suggestOnTriggerCharacters": false, gets rid of the auto-suggestions completely.

您还可以仅指定一种语言的设置,例如

You can also specify the settings for just one language, e.g.

"[php]":  {
  "editor.suggestOnTriggerCharacters": false,
},