You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在HTML文件中设置VS Code的Minimap Section Headers?

在HTML中启用VS Code Minimap Section Headers的正确方式

VS Code v1.88推出的Minimap Section Headers对HTML文件的支持,需要用适配HTML注释规范的region标记格式,你之前试的两种写法都不符合要求,所以没生效,具体正确写法如下:

  • 章节开头:<!-- region [自定义章节名] -->
  • 章节结尾:<!-- endregion -->

举个可直接复用的示例:

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <!-- region 页面元数据 -->
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Minimap测试页</title>
    <!-- endregion -->

    <!-- region 全局样式 -->
    <style>
        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }
        body {
            padding: 2rem;
            font-family: "Microsoft Yahei", sans-serif;
        }
    </style>
    <!-- endregion -->
</head>
<body>
    <!-- region 头部导航 -->
    <header>
        <nav>
            <a href="#home">首页</a>
            <a href="#about">关于</a>
        </nav>
    </header>
    <!-- endregion -->

    <!-- region 主体内容 -->
    <main>
        <h1>测试Minimap章节标题</h1>
        <p>添加region注释后,Minimap上会显示对应的章节名称</p>
    </main>
    <!-- endregion -->
</body>
</html>

设置完成后,打开VS Code的Minimap,就能看到对应章节标题显示在 minimap 的对应位置了。

额外确认两点:

  1. 确保你的VS Code版本是v1.88或更高
  2. 检查设置editor.minimap.sectionHeaders.enabled是否为true(默认是启用状态)

内容的提问来源于stack exchange,提问作者Aymen Hmani

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.25 21:52:08