如何在VS Code中获得类似Atom的自动完成?

huangapple go评论49阅读模式
英文:

How can I get Atom-like autocomplete in VS Code?

问题

当自动完成时,大多数编辑器要么覆盖光标前面的单词,要么只插入完成而不触及其他文本。Atom在这两者之间找到了一个我非常喜欢的平衡点,但有点难以用言语表达。它基本上会替换完成的后缀中包含的单词部分。让我举几个例子,管道符(|)代表光标,每个例子中,我们自动完成“HelloWorld”:

  • Hello|You -> HelloWorld|You
  • Hello|World -> HelloWorld|
  • Hello|InTheWorld -> HelloWorld|InTheWorld
  • Hello|rld1234 -> HelloWorld|1234

我发现这个功能很少出错,而我不需要考虑是否要替换某些内容。而且习惯了这种方式之后,我发现其他两种选项(始终替换和从不替换)经常会做我不想要的事情。

我最后决定要从Atom切换到其他编辑器。是否有办法让VS Code的自动完成功能像Atom一样工作?

英文:

When auto-completing, most editors either overwrite the word your cursor is in front, or just insert the completion without touching any other text. Atom has a happy medium between the two that I really like, but is a bit hard to put into words. It basically replaces any part of the word that is a suffix of the completion. Let me give some examples, the pipe (|) is the cursor and in each example, we autocomplete "HelloWorld":

  • Hello|You -> HelloWorld|You
  • Hello|World -> HelloWorld|
  • Hello|InTheWorld -> HelloWorld|InTheWorld
  • Hello|rld1234 -> HelloWorld|1234

I've found that this rarely gets it wrong, without me needing to think about whether I wanted to replace something or not. And having gotten used to it, I find both the other options (always replacing and never replacing) do something I didn't want often.

I'm finally looking at switching away from Atom. Is there a way to make autocomplete work in VS Code the way it does in Atom?

答案1

得分: 2

在Bash / readline / inputrc中,这个功能(或者与此非常相似的功能)的设置被称为skip-completed-text。据我所知,截止到我写这个回答的时间,VS Code只有一个名为editor.suggest.insertMode的设置,它只有两个选项,分别是"insert"(从不替换任何内容)和"replace"(始终替换由当前语言模式的语言扩展定义的后续文本范围,或类似于此的内容),以及一些相关的键盘快捷键绑定点。

所以,如果你真的想要这样的功能,正确的下一步是将其提出为一个功能请求,提交给VS Code的维护者,可能作为现有editor.suggest.insertMode设置的新值。如果你这样做,请确保详细描述它应该如何行为(例如,在你的问题帖子中展示的示例),并请在此答案下面的评论中提供一个链接到你的功能请求,或者建议编辑此答案以添加一个链接。如果你希望它被添加到待办事项列表中,你需要在一定时间内获得一定数量的点赞反应,所以我建议你向你的朋友/同事/同行宣传你的功能请求,并在开发平台上进行宣传,比如r/vscode

英文:

In Bash / readline / inputrc, this feature (or something very similar to it)'s setting is called skip-completed-text. As far as my knowledge goes, VS Code just has a setting called editor.suggest.insertMode, which (at the time of this writing), only has "insert" (never replace anything) and "replace" (always replace the following text range- as defined by the language extension for the current language mode (or something like that)) as options (and some associated keyboard shortcut binding points).

So (and I hope I'm right about this- I'm not 100% confident), the correct next step if you really want such a feature is to raise it as a feature-request to the VS Code maintainers, probably as a new value to the existing editor.suggest.insertMode setting. If you do that, make sure to describe in detail how it should behave (Ex. showing the example you've shown in your question post here), and please either comment under this answer post with a link to your feature request, or suggest an edit to this answer post to add a link to it. You'll need to get a certain number of thumbs up reactions within a certain time period if you want it to get added to the backlog, so I'd suggest to promote your feature request to your friends / peers / colleagues, and on dev platforms like r/vscode.

huangapple
  • 本文由 发表于 2023年7月23日 21:18:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/76748445.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定