跪拜 Guibai
← All articles
Frontend

Turn VSCode's Minimap into a Navigation Map with MARK Comments

By 40岁搬砖工 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

For any developer working in large single-file components — common in Vue, React, or any framework — this technique eliminates a constant source of friction. It's a zero-cost, zero-plugin way to turn VSCode's minimap from a vague shape preview into a precise navigation tool, keeping flow intact during rapid iteration.

Summary

As Vue projects grow, single files routinely exceed a thousand lines. Jumping between template and script sections by dragging the scrollbar breaks flow and wastes time. The built-in outline view is slow, and manual bookmarks add maintenance overhead.

One solution: use `// MARK:` or `<!-- MARK: -->` comments. VSCode's minimap picks them up and displays the label text directly on the minimap, creating a visual index of every major section. Adding a dash (`// MARK: - Section`) inserts a separator line for extra clarity.

Custom regex patterns in the editor settings let developers fine-tune how MARK comments are parsed, including stripping trailing whitespace or handling different comment syntaxes. The result is a scrollbar that doubles as a labeled map of the file.

Takeaways
VSCode's minimap natively recognizes `// MARK:` and `<!-- MARK: -->` comments and displays the label text directly on the minimap.
Adding a dash after MARK (e.g., `// MARK: - Section`) creates a visual separator line in the minimap.
Custom regex patterns in `editor.minimap.sectionHeaderRegex` allow fine-tuning how MARK comments are parsed.
MARK comments work with JavaScript, TypeScript, HTML, and any language that supports line or block comments.
No plugins or extensions are required — it's a built-in VSCode feature.
Conclusions

Most developers overlook this built-in feature because it's not advertised in VSCode's UI — it's a hidden productivity gem.

The technique is especially valuable for Vue/React developers who write large single-file components with mixed template, script, and style sections.

Custom regex support means teams can standardize a MARK comment format across a codebase, making navigation predictable for everyone.

This approach is lighter than bookmarks or outline panels because it requires zero maintenance — comments are part of the code itself.

Concepts & terms
Minimap
VSCode's built-in code thumbnail displayed on the right side of the editor. It provides a bird's-eye view of the file and supports section markers that highlight labeled regions.
MARK comment
A special comment format (`// MARK:` or `<!-- MARK: -->`) that VSCode's minimap recognizes as a section header. The text after MARK appears directly on the minimap for quick visual navigation.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗