[Q&A] 如何为 Vivado / Quartus 等各种 IDE 设置自定义编辑器 ?

Posted @ 2025-02-20 12:11  bitlogic

实际上,最主要的是我们只要知道编辑器的命令行接口,即 Command Line Interface (CLI),就可以在其他地方配置调用该编辑器,而这个不难得到,如 VS Code CLI,查看文档,我们可以用code -g file:line[:character]打开文件file,并跳转到指定的行和可选的列位置。

接下来我们只需要打开 IDE 的配置窗口,一般他们都会给出提示用来说明如何传递命令行参数,例如我们今天举例的三款 FPGA 开发 IDE 都只支持文件名及行号选项,分别是:ISE$1$2Vivado[file name][line number]以及 Quartus%f%l。以 VSCode 举例配置如下:

  • ISE : D:\\Tools\\Microsoft\ VS\ Code\\Code.exe -g $1:$2
  • Quartus : "D:\Tools\Microsoft VS Code\Code.exe" -g %f:%l
  • Vivado : "D:/Tools/Microsoft VS Code/Code.exe" -g [file name]:[line number]

同理,若使用 Vim,只需在 Vim 中运行:h vim-arguments即可查看启动 Vim 的命令行参数,类似的,配置gVim如下:

  • ISE : D:\\Tools\\Vim\\vim90\\gvim.exe $1 +$2
  • Quartus : "D:\Tools\Vim\vim90\gvim.exe" %f +%l
  • Vivado : "D:/Tools/Vim/vim90/gvim.exe" [file name] +[line number]

总之,查看你所用编辑器的命令行接口 CLI,然后按照其相应的格式传入具体的实参表达式即可。下面分享我个人对几个 IDE 配置 gVim 编辑器的自定义设置,供参考:

  • ISE : D:\\Tools\\Vim\\vim91\\gvim.exe --servername GISE --remote-silent +$2 $1
  • Quartus : "D:\Tools\Vim\vim91\gvim.exe" --servername GQUARTUS --remote-silent +%l %f
  • Vivado : "D:/Tools/Vim/vim91/gvim.exe" --servername GVIVADO --remote-silent +[line number] [file name]
  • Source Insight : "D:\Tools\Vim\vim91\gvim.exe" --servername GSRCINS --remote-silent +%l %f
  • Visual Studio : --servername GVS --remote-silent "+call cursor($(CurLine), $(CurCol))" $(ItemPath)
  • Keil MDK : --servername GKEIL --remote-silent "+call cursor(~E+1, ^E??1)" "#E"
  • DVT Eclipse : --servername GDVT --remote-silent +${selected_resource_line} "${selected_resource_loc}"

如果你也同时在使用 VSCode 和 gVim,你甚至可以在 VSCode 中配置快捷键,从而使用 gVim 来快速打开当前文件,只需要在tasks.json中创建一个全局任务,如下所示:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Edit with Vim",
            "type": "shell",
            "command": "gvim",
            "args": [
                "--servername",
                "GCODE",
                "--remote-silent",
                "+${lineNumber}",
                "${file}"
            ],
            "problemMatcher": [],
            "presentation": {
                "panel": "new",
                "close": true,
                "reveal": "never"
            }
        }
    ]
}

然后为该任务创建按键绑定即可,比如我绑定快捷键为 Alt+` 如下示例:

[
    {
        "key": "alt+oem_3",
        "command": "workbench.action.tasks.runTask",
        "args": "Edit with Vim"
    }
]

作者:bitlogic

出处:https://www.cnblogs.com/bitlogic/p/18726280

版权:本作品采用「署名-非商业性使用-相同方式共享 4.0 国际」许可协议进行许可。

posted @   bitlogic  阅读(27)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· winform 绘制太阳,地球,月球 运作规律
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
点击右上角即可分享
微信分享提示
选择主题