VSCode:通过路径智能感知显示用户片段

发布于 2025-01-09 14:24:01 字数 525 浏览 0 评论 0原文

我正在尝试将路径智能感知优先于我的用户片段,或者只是将它们与其他非用户片段真正分组。当前的行为是user snippets ->路径 ->其他片段如屏幕截图所示:

在此处输入图像描述

我需要导航路径,我不知道结构,但每个级别我都必须向下滚动到建议,这非常烦人。我已经禁用了一些代码片段,但它仍然很烦人,并且不值得仅仅因为这个而关闭自定义代码片段。

我尝试过的一些设置是 "editor.snippetSuggestions": "inline""editor.quickSuggestions": { "strings": false" }。还尝试了最流行的路径自动完成 ?

我是唯一对此感到恼火的人吗?这是默认行为还是我弄乱了我的配置

I'm trying to prioritize path intellisense over my user snippets, or just group them with other non-user snippets really. The current behaviour is user snippets -> paths -> other snippets as seen in the screenshot:

enter image description here

I need to navigate paths I don't know the structure but each level I have to scroll down to the suggestion and it's very annoying. I have disabled some snippets, but it's still annoying and it's not worth to turn off custom snippets just because of this.

Some settings I tried are "editor.snippetSuggestions": "inline" and "editor.quickSuggestions": { "strings": false" }. Also tried most popular path autcomplete extensions.

Am I the only one annoyed by this? Is this the default behaviour or did I messed up my config? Thanks in advance.

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

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

发布评论

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

评论(1

等你爱我 2025-01-16 14:24:01

对于 HTML,

我设法找到了解决此问题的三种解决方法:

  1. 一种选择是利用键盘上的向下箭头从代码片段列表的末尾进行导航。在提供的示例中,最后一个片段是路径自动完成建议,
    查看实际效果:

https://i.imgur.com/9s6rhCf.gif

  1. 另一种方法是使用退格键删除斜杠,然后再次输入。

输入图像这里的描述

  1. 第三种方法是在第一个斜杠之后简单地键入第二个斜杠。

输入图像这里的描述

对于 JavaScript/TypeScript

对于 JavaScript 或 TypeScript 等其他语言,我使用 path-intellisense 扩展(扩展 ID: christian-kohler.path-intellisense),在用户 JSON 配置中使用以下设置:

"typescript.suggest.paths": false,
"javascript.suggest.paths": false,
"path-intellisense.autoTriggerNextSuggestion": false,
"path-intellisense.autoSlashAfterDirectory": false,
"path-intellisense.absolutePathToWorkspace": true

通过调整这些设置,我确保使用扩展而不是 Visual Studio Code for JavaScript 中的默认路径自动完成功能和打字稿。

autoSlashAfterDirectory 设置可防止在目录后自动添加斜杠,而 autoTriggerNextSuggestion 可确保建议小部件在从键盘手动输入斜杠之前不会自动显示。

此配置产生所需的结果,如下所示:

在此处输入图像描述

For HTML

I have managed to find three workarounds for this issue:

  1. One option is to utilize the down arrow on the keyboard to navigate from the end of the snippet list. In the provided example, the last snippet is the path autocomplete suggestion,
    see it in action :

https://i.imgur.com/9s6rhCf.gif

  1. Another method involves deleting the slash using the backspace key and then typing it again.

enter image description here

  1. A third approach is to simply type a second slash after the initial one.

enter image description here

For JavaScript/TypeScript

For other languages like JavaScript or TypeScript, I use the path-intellisense extension (extension ID: christian-kohler.path-intellisense) with the following settings in the user JSON configuration:

"typescript.suggest.paths": false,
"javascript.suggest.paths": false,
"path-intellisense.autoTriggerNextSuggestion": false,
"path-intellisense.autoSlashAfterDirectory": false,
"path-intellisense.absolutePathToWorkspace": true

By adjusting these settings, I ensure that the extension is used instead of the default path autocomplete feature in Visual Studio Code for JavaScript and TypeScript.

The autoSlashAfterDirectory setting prevents automatic addition of a slash after a directory, and autoTriggerNextSuggestion ensures that the suggestion widget doesn't appear automatically until a slash is entered manually from the keyboard.

This configuration produces the desired result, as demonstrated here :

enter image description here

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