Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>KakaxiNew to Visual Studio Code? Get it now.
Kakaxi

Kakaxi

sosososolong

|
10 installs
| (0) | Free
Insert snippets in multi files by custom settings in operation.json5
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

VSCode Kakaxi

介绍

不同的项目自定义一些快速定位, 快速插入代码片段的快捷操作

代码图

  • CustomOperationProvider

    • prepareSelectedAction 根据 selectedKey 获取用户选择的CustomOperation对象(包含多个Operation)
      • selectedKey: clear cache 清空缓存 return
      • operations: 所有的配置好的CustomOperation集合
      • selected: 在operations中找到与selectedKey对应的CustomOperation
      • 执行selected.prepareParameters
  • CustomOperation

    • this.prepareParameters(); parameters: ParameterInfo集合, 即将要获取的所有参数的容器
      • this.operations: Operation集合字段 遍历
        • op 当前Operation对象
        • op.snippets 有值 遍历
          • snippet 当前的文本片段
          • this.getParameter(snippet, parameters)
            • 正则查找snippet中的参数模板: $#默认值$#注释/标题(表单Label)$#别名供其他地方直接使用end

软件架构

软件架构说明

安装教程

  1. xxxx
  2. xxxx
  3. xxxx

使用说明

  1. 安装插件后, 项目根目录创建operation.json5文件
  2. 配置格式如下
    [
      // 插入代码
      {
        // 文当前的操作添加标题, 会出现在下拉选择框中
        "key": "log",
        // 要入代码的目标文件部分路径, 如果为空, 则默认选择当前打开的文件
        "path": "src/api/records.js",
        // 一个文件中的所有子操作
        "operations": [
          // 有时候一个操作在一个文件中, 可能包含多个子操作, 每个子操作进行一次定位和插入代码片段动作
          {
            // 正则数组, 匹配任意一个, 则取消当前子操作, 正则为正则的字符串格式, 如'/<el-table-column type="selection" align="center"\\s*\\/>/g'
            // 注意正则语法的格式: "/../[g]"
            // 注意如果需要转义字符"\", 如正则匹配"."为"\.", json5中"\"也会被视为转义, 所以应Json5中应该为: "\\."
            "cancelMatches": [],
            // 格式同上, 如果有多个, 则一个一个进行尝试匹配
            "matches": [],
            // 如果有多个snippet, 那么插件会让程序员选择
            "snippets": [
              "console.log('hello world')"
            ],
            // 0表示在matches中正则匹配的位置后面插入snippet; 1表示在匹配位置的下一行插入snippet
            "insertType": 1
          }
        ],
        // operations的操作位置就是path指定的文件, 没有指定path的话就是当前文件
        // 如果同时还需要操作其他文件, 那么需要指定nextAction字段, 结构同上
        // TODO: 取消; 使用operation添加path属性即可
        "nextAction": {
          "path": "xxx",
          "operations": [
            {
              "path": "xxx",
              "cancelMatches": [],
              "matches": [],
              "snippets": [],
              "insertType": 1
            }
          ]
        }
      },
    
      // 快速定位
      {
        "key": "go to: api file",
        "path": "src/api/records.js",
        "operations": [
          {
            "matches": []
          }
        ]
      },
      // 清除配置缓存, 重新读取配置文件(修改配置文件后, 如添加新的操作后, 需要重新读取配置文件)
      {
        "key": "clear cache"
      }
    ]
    

参与贡献

  1. Fork 本仓库
  2. 新建 Feat_xxx 分支
  3. 提交代码
  4. 新建 Pull Request

特技

  1. 使用 Readme_XXX.md 来支持不同的语言,例如 Readme_en.md, Readme_zh.md
  2. Gitee 官方博客 blog.gitee.com
  3. 你可以 https://gitee.com/explore 这个地址来了解 Gitee 上的优秀开源项目
  4. GVP 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
  5. Gitee 官方提供的使用手册 https://gitee.com/help
  6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 https://gitee.com/gitee-stars/
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft