跳至主要內容
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?

4563博客

全新的繁體中文 WordPress 網站
  • 首頁
  • VS Code 自定义联想输入词库?
未分類
16 3 月 2021

VS Code 自定义联想输入词库?

VS Code 自定义联想输入词库?

資深大佬 : dLvsYgJ8fiP8TGYU 1

由于需要编辑一些程序的配置文件,且经常需要输入固定的一些(不超过 10 组)变量名称(很长,不好手打),希望有什么方法 /插件可以简化输入过程。

目前使用的 vscode intellisense 有联想 /自动补全功能。但似乎只能从当前文件所使用的语言对应的关键词 list 中显示,或者从上下文「已经存在的」变量名中选择补全,因此第一次输入的时候还是没法自动化;

系统输入法自定义词库似乎也在 vscode 界面无法触发;

还有啥方法能在 vscode 里面自定义词库的?看了一下 intellisense 的文档没发现类似功能

    • -最后有一个大胆的想法:根据不同文件拓展名 [.ext01, .ext02…],匹配不同的词库 [list01, list02…] (就是不知道有没有人真的做出了这样的插件了)
大佬有話說 (7)

  • 資深大佬 : codehz

    你可能需要的是 snippet
    可以使用类似这样的写法指定在哪些语言生效
    {
    “My Awesome Snippet”: {
    “prefix”: “abc”,
    “lang”: [“css”, “php”, “html”],
    “body”:[
    “[email protected]#”
    ]
    }
    }

  • 資深大佬 : codehz

    上面的例子当我没说,看了一眼并不能声明多个语言,不过你可以手动写好几份,反正都是一次性编写的事情

  • 資深大佬 : noqwerty

    @codehz #2 可以在 global snippet file 里面定义:Multi-language and global user-defined snippets are all defined in “global” snippet files (JSON with the file suffix .code-snippets), which is also accessible through Preferences: Configure User Snippets. In a global snippets file, a snippet definition may have an additional scope property that takes one or more language identifiers, which makes the snippet available only for those specified languages. If no scope property is given, then the global snippet is available in all languages.

    参考链接: https://code.visualstudio.com/docs/editor/userdefinedsnippets#_language-snippet-scope

  • 資深大佬 : Trim21

    如果是编辑 JSON toml 这类的配置文件可以写个 JSON schema

  • 資深大佬 : molvqingtai

    有个人工智能补全插件挺好用的,就是有点耗内存 https://github.com/codota/tabnine-vscode

  • 資深大佬 : imrealadmin

    vscode 支持多个文件的关键词推荐的,配置如下:

    “`json
    “editor.wordBasedSuggestions”: true,
    “editor.wordBasedSuggestionsMode”: “allDocuments”,
    “`

  • 主 資深大佬 : dLvsYgJ8fiP8TGYU

    @codehz 感谢,已经用 snippet 实现了自定义词库

文章導覽

上一篇文章
下一篇文章

AD

其他操作

  • 登入
  • 訂閱網站內容的資訊提供
  • 訂閱留言的資訊提供
  • WordPress.org 台灣繁體中文

51la

4563博客

全新的繁體中文 WordPress 網站
返回頂端
本站採用 WordPress 建置 | 佈景主題採用 GretaThemes 所設計的 Memory
4563博客
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?
在這裡新增小工具