Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>Markdown Template (.mt)New to Visual Studio Code? Get it now.
Markdown Template (.mt)

Markdown Template (.mt)

lupee

|
4 installs
| (0) | Free
Markdown with @import: compose documents from local files and URLs. A dedicated editor with Source, Assembled and Rendered views, formatting, heading numbers, copying the expanded markdown and exporting it to Markdown or HTML.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Markdown Template (.mt) — Markdown with @import

English · 简体中文

English

Write modular Markdown documents in VS Code. Markdown Template adds an @import directive to Markdown, so one .mt file can include other Markdown files, source code, JSON, YAML, HTML, images and remote URLs. Edit the source, check the assembled Markdown and preview the rendered page in a single editor, then copy the result or export it as one .md file or a standalone .html page.

Great for technical documentation, API docs, specs, design documents, READMEs, knowledge bases and AI prompt files: anywhere you want to reuse Markdown snippets (partials / transclusion) instead of copying and pasting them.

Features

  • Markdown include / import: @import "parts/intro.md" merges a file in place. Import a line range, a single section by its heading, or shift heading levels. Nested imports work, with circular-import detection.
  • Import anything: Markdown is merged; source code, JSON, YAML, HTML and any other file become fenced code blocks with syntax highlighting; images become images; https:// URLs are fetched and cached, and GitHub blob links are rewritten to raw automatically.
  • Three views, one editor: Source (edit the .mt file), Assembled (every @import expanded) and Rendered (live Markdown preview). Switch with Ctrl/Cmd+E, double-click in the preview to jump back to the source line, and scroll stays in sync.
  • Live preview with auto refresh: the views update as you type and when an imported file changes, even before it is saved. Import errors are shown inline and in the Problems panel.
  • Outline and heading numbers: headings are numbered automatically (1, 1.1, 1.1.1) across all imported files. The outline (table of contents) panel jumps to any heading and marks sections with git changes.
  • Annotations: write review notes as %%note%%. They are highlighted in the editor, listed in the Annotations panel, and removed automatically when you copy or export.
  • Markdown table tools: align all Markdown tables in one click (CJK-aware: Chinese, Japanese and Korean characters count as two columns, so tables really line up), insert table rows from the context menu, and use a blank row to split a long table into sections.
  • Markdown formatter: Prettier-based formatting that keeps @import lines intact and only writes back if the rendered result is unchanged.
  • Git in the editor: change bars in the gutter and on the scrollbar, an inline diff, and stage or revert a single change.
  • Copy and export: copy the expanded Markdown, export a .md file, or export a standalone .html file with inline styles and dark-mode support, ready to open in any browser.
  • Claude Code integration: with Claude Code installed, the Claude toolbar button inserts an @file#12-18 reference to the selected lines (or the whole file) into the Claude Code chat input.
  • Feels like VS Code: syntax colors follow your color theme; familiar keybindings, multi-cursor and find & replace (including in selection); @import path autocomplete and Ctrl/Cmd+Click to open; undo, save and hot exit work as usual; reopen in the plain text editor at any time.
  • Safe by default: strict content security policy, sanitized HTML, no scripts from remote content; remote and out-of-workspace imports are disabled in untrusted workspaces.
  • 7 UI languages: English, 中文, Deutsch, Français, 日本語, 한국어, Русский, switchable independently of the VS Code display language.

Quick start

  1. Create a file named guide.mt:

    # Product Guide
    
    @import "parts/intro.md"
    @import "parts/api.md#Authentication" {heading_offset=1}
    @import "config/settings.json"
    @import "https://github.com/user/repo/blob/main/CHANGELOG.md" {line_end=20}
    
  2. Open it. It opens in the Markdown Template editor, in the Source view.

  3. Click Assembled or Rendered in the toolbar, or press Ctrl/Cmd+E, to see the result.

  4. Use Copy or Export ▾ → Markdown File / HTML File to share it.

@import cheat sheet

Path Meaning
parts/a.md, ../a.md Relative to the current file
/abs/path/a.md, ~/notes/a.md Absolute path, home directory
${workspaceFolder}/docs/a.md Workspace root
https://example.com/a.md Remote URL (GitHub blob links become raw)
a.md#Installation Only the section under that heading
Option Meaning
{line_begin=10 line_end=-1} Line range (1-based, negative counts from the end)
{heading_offset=1} Shift imported headings one level down
{as="yaml"} Import as a code block in the given language
{code_block=true} / {code_block=false} Show Markdown as raw code, or render a non-Markdown file as Markdown
{optional=true} Skip silently when the file is missing

Write <!-- @import "a.md" --> instead, and other Markdown tools will treat the line as a comment.

Keyboard shortcuts

Shortcut Action
Ctrl/Cmd+E Cycle Source → Assembled → Rendered
Ctrl/Cmd+Shift+V Toggle Source ↔ Rendered (opens the preview from the text editor)
Shift+Alt+F Format the document
Ctrl/Cmd+F Find and replace
Ctrl/Cmd+Click on an @import path Open the imported file or URL

FAQ

  • Prefer the plain text editor? Click Text in the toolbar, or make it the default with "workbench.editorAssociations": { "*.mt": "default" }. The preview stays available via Ctrl/Cmd+Shift+V.
  • Use it with other Markdown extensions? .mt is its own language (mt). To let Markdown-only extensions handle it, add "files.associations": { "*.mt": "markdown" }.
  • Which settings are there? Open Settings and search for mt.: default view, remote imports, import depth, preview font and line breaks, scroll sync and more.

简体中文

在 VS Code 里写模块化的 Markdown 文档。 Markdown Template 为 Markdown 增加了 @import 指令:一个 .mt 文件可以引入其它 Markdown 文件、源代码、JSON、YAML、HTML、图片和网络上的 URL 内容。在同一个编辑页里编辑源码、查看拼接后的 Markdown、预览渲染效果,然后一键复制,或导出为一个 .md 文件、一个可以直接打开的 .html 网页。

适合技术文档、接口文档、需求与设计文档、README、知识库、AI 提示词文件:凡是需要复用 Markdown 片段、不想到处复制粘贴的地方都能用上。

功能特色

  • Markdown 引入 / 合并:@import "parts/intro.md" 把文件就地合并进来;可以只引入某几行、只引入某个标题下的章节,也可以整体调整标题层级;支持嵌套引入,自动检测循环引用。
  • 什么都能引入:Markdown 直接合并;源代码、JSON、YAML、HTML 等任意文件作为带语法高亮的代码块引入;图片按图片显示;https:// 网址自动获取并缓存,GitHub 的 blob 链接自动改成原始文件地址。
  • 一个编辑页,三种视图:源码(编辑 .mt 原文)、组装(所有 @import 展开后的结果)、渲染(实时 Markdown 预览);Ctrl/Cmd+E 切换,在预览里双击跳回源码对应行,滚动位置互相跟随。
  • 实时预览、自动刷新:边写边更新,被引入的文件改动后(即使还没保存)也立即刷新;引入出错时就地标出,并出现在“问题”面板里。
  • 导航目录与标题编号:标题自动编号(1、1.1、1.1.1),被引入文件里的标题一起编号;左侧导航面板(文档目录)点击即可定位,有 git 改动的章节会标出来。
  • 批注:用 %%批注%% 写审阅意见,编辑页里高亮显示,批注面板集中列出,复制和导出时自动去掉。
  • Markdown 表格工具:一键按列对齐所有 Markdown 表格,中文、日文、韩文按两个字符宽计算,表格真正竖直对齐;右键在上方或下方插入表格行;用一行空行把长表格分成几段。
  • Markdown 格式化:基于 Prettier,@import 指令行原样保留,确认渲染结果不变才写回。
  • 编辑页里的 git:行号旁和滚动条上显示改动,点开可以看内嵌差异,单独暂存或还原某一处改动。
  • 复制与导出:复制展开后的 Markdown,导出 .md 文件,或导出样式内联、支持深色模式的独立 .html 文件,用浏览器直接打开。
  • 配合 Claude Code:装了 Claude Code 时,工具栏的 Claude 按钮把选中行(没选中时整个文件)的 @文件#12-18 引用直接插入 Claude Code 的对话输入框。
  • 和 VS Code 一样顺手:语法配色跟随颜色主题;熟悉的快捷键、多光标、查找替换(支持仅在选中区域内);@import 路径自动补全,Ctrl/Cmd+点击 打开被引入的文件;撤销、保存、热退出照常;随时可以换回 VS Code 自己的文本编辑器。
  • 默认安全:严格的内容安全策略,HTML 经过净化,远程内容不执行脚本;不受信任的工作区里禁用网址引入和工作区外的路径。
  • 7 种界面语言:中文、English、Deutsch、Français、日本語、한국어、Русский,可以独立于 VS Code 的显示语言切换。

快速开始

  1. 新建文件 guide.mt:

    # 产品手册
    
    @import "parts/intro.md"
    @import "parts/api.md#认证" {heading_offset=1}
    @import "config/settings.json"
    @import "https://github.com/user/repo/blob/main/CHANGELOG.md" {line_end=20}
    
  2. 打开它,默认进入 Markdown Template 编辑页的 源码 视图。

  3. 点工具栏的 组装 或 渲染,或按 Ctrl/Cmd+E,查看拼接和渲染的结果。

  4. 用 复制 或 导出 ▾ → Markdown 文件 / HTML 文件 分享出去。

@import 速查

路径写法 含义
parts/a.md、../a.md 相对于当前文件所在目录
/绝对路径/a.md、~/notes/a.md 系统绝对路径、家目录
${workspaceFolder}/docs/a.md 工作区根目录
https://example.com/a.md 网络地址(GitHub 的 blob 链接自动改成原始文件地址)
a.md#安装 只引入“安装”这个标题下的章节
参数 含义
{line_begin=10 line_end=-1} 行范围(从 1 开始,负数从末尾倒数)
{heading_offset=1} 被引入的标题整体降一级
{as="yaml"} 作为指定语言的代码块引入
{code_block=true} / {code_block=false} 把 Markdown 显示成源码,或把非 Markdown 文件当 Markdown 渲染
{optional=true} 文件不存在时静默跳过

写成 <!-- @import "a.md" --> 也可以,用其它 Markdown 工具打开时这一行会被当作注释。

快捷键

快捷键 作用
Ctrl/Cmd+E 源码 → 组装 → 渲染 循环切换
Ctrl/Cmd+Shift+V 源码 ↔ 渲染(在文本编辑器里则打开预览)
Shift+Alt+F 格式化文档
Ctrl/Cmd+F 查找替换
Ctrl/Cmd+点击 @import 路径 打开被引入的文件或网址

常见问题

  • 更习惯普通文本编辑器? 点工具栏的 文本,或在设置里加 "workbench.editorAssociations": { "*.mt": "default" } 让它成为默认;预览仍然可以用 Ctrl/Cmd+Shift+V 打开。
  • 能和其它 Markdown 插件一起用吗? .mt 是独立的语言 mt。想让只认 Markdown 的插件也作用于它,在设置里加 "files.associations": { "*.mt": "markdown" }。
  • 有哪些设置? 打开设置搜索 mt.:默认视图、网址引入、引入深度、预览字体与换行、滚动跟随等。

License: MIT

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft