




Verilog语法高亮不生效需先启用Verilog-SystemVerilog插件并手动绑定语法;支持module折叠与缩进需配置fold_at_module等参数;跨文件跳转依赖CTags索引;避免.log/.vcd等非Verilog文件被错误高亮。
Sublime 默认不带 Verilog 支持,必须安装第三方语法包。最常用的是 Verilog-SystemVerilog 插件(由 travisgoodsill 维护),它比旧版 Verilog 插件支持更全,包括 interface、package、logic、var 等 SystemVerilog 关键字。
安装后,打开一个 .v 或 .sv 文件,检查右下角状态栏:如果显示 Plain Text,说明语法未绑定;点击它 → 选择 Verilog-SystemVerilog → Verilog 或 SystemVerilog(根据文件类型选)。这一步漏掉,高亮永远不出现。
.hvl 或无后缀 testbench,需手动设置Preferences → Package Settings → Verilog-SystemVerilog → Settings,确认 "extensions" 列表里包含你用的后缀,比如添加 "hvl"
Ctrl+Shift+P → Reload Syntax
默认 Verilog 折叠基于括号层级,对 module、begin/end 块支持弱。需要修改插件的 folding.sublime-settings 或覆盖语法定义。
推荐做法:在 Preferences → Package Settings → Verilog-SystemVerilog → Settings 中加入:
{
"fold_at_begin_end": true,
"fold_at_module": true,
"indent_submodules": true
}
这样 module ... endmodule、begin ... end、function ... endfunction 都能折叠。注意:fold_at_module 依赖正则匹配 module 开头行,若你写成 module #(...) 多空格或换行,可能失效。
Verilog-SystemVerilog/verilog-systemverilog.sublime-syntax 控制,不建议直接改;如需自定义 tab 宽度,在 View → Indentation → Convert Indentation to Spaces 后设为 2 或 4indentation error,尤其在 `ifdef 块里Sublime 原生不解析 Verilog 作用域,Goto Definition(F12)默认无效。得靠 CTags 或 SublimeCodeIntel 这类索引工具,但它们对 Verilog 支持有限且配置麻烦。
更轻量的方案是用 Verilog-SystemVerilog 自带的符号列表(Command Palette → Verilog: Show Symbols),它基于正则提取 module、task、function 名,可快速跳转——但仅限当前文件。
tags 文件。用 ctags -R --language-force=verilog --fields=+nia --c-kinds=+p --verilog-kinds=+psit .(要求 Universal Ctags,不是 exuberant)CTags 插件,并确保 ctags_path 指向正确二进制;否则 F12 点击 my_module 会提示 No definition found
auto_complete_triggers 可追加 Verilog 触发字符,例如在用户设置里加:{"selector": "source.verilog", "characters": ".("},让输入 . 时弹出端口补全这是典型语法劫持:插件把所有含 .v 的后缀都绑定了 Verilog 语法,而 modelsim.log、dump.vcd 实际是纯文本或结构化文本,不该高亮。
解决方法是显式解除错误绑定。打开 View → Syntax → Open all with current extension as...,选 Plain Text;或者更彻底:在 Preferences → Settings — Syntax Specific 里,对 .log 类型加:
{
"syntax": "Packages/Text/Plain text.tmLanguage"
}
同理,.vcd 推荐用 Verilog-SystemVerilog/VCD 专用语法(插件自带),它比通用 Verilog 更准——比如能区分 $dumpvars 和普通变量名。
.sdf、.sdc 文件:它们是时序约束,语法完全不同,应单独绑定 Synopsys SDC 或 Text 语法
.hw 作顶层,可在项目根目录建 .sublime-project,在 "folders" 下指定 "syntax_override"