Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>File To MarkdownNew to Visual Studio Code? Get it now.
File To Markdown

File To Markdown

luban

|
2 installs
| (0) | Free
快速将多个文件或文件夹的代码合并成一个Markdown文件
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

File To Markdown / 代码转 Markdown

English | 中文


English

File To Markdown is a VS Code extension designed to streamline the workflow between programmers and AI assistants (like ChatGPT, Claude, DeepSeek, etc.).

It allows you to quickly merge code from multiple files, folders, or specific code snippets into a single, well-formatted Markdown file. This makes it incredibly easy to provide context to an AI for code analysis or debugging.

✨ Features

  • Batch Processing: Select multiple files or entire folders in the Explorer to merge them into one Markdown file.
  • Code Snippets: Select a specific block of code in the editor to convert just that snippet (includes line number context).
  • Smart Formatting: Automatically wraps code in Markdown code blocks with the correct language identifier (e.g., js, php, vue).
  • Context Aware: Adds the relative file path before each code block so the AI knows exactly which file the code belongs to.
  • Keyboard Shortcut: Use one shortcut (Ctrl+Shift+Alt+M) to handle all scenarios.

🚀 How to Use

1. Convert Files or Folders (Explorer Mode)

Perfect for sending entire modules or project structures to AI.

  1. Open the Explorer side bar.
  2. Select one or more files/folders (hold Ctrl or Cmd to multi-select).
  3. Right-click and choose "将代码转换为 Markdown" (Convert Code to Markdown).
  4. Alternatively, press the shortcut Ctrl+Shift+Alt+M after selecting.

2. Convert Code Snippets (Snippet Mode)

Perfect for asking questions about a specific function or logic block.

  1. Open a file in the editor.
  2. Select the code text you want to share.
  3. Right-click in the editor and choose "将代码转换为 Markdown".
  4. Alternatively, press the shortcut Ctrl+Shift+Alt+M.
  5. Note: The output will include the file path and line numbers (e.g., lines 10-25).

3. Convert Active File (Whole File Mode)

Quickly convert the file you are currently viewing.

  1. Open a file in the editor.
  2. Ensure no text is selected.
  3. Press the shortcut Ctrl+Shift+Alt+M (or right-click).
  4. The entire file content will be converted.

⌨️ Keyboard Shortcuts

OS Shortcut
Windows / Linux Ctrl + Shift + Alt + M
macOS Cmd + Shift + Alt + M

中文

File To Markdown 是一款旨在提升程序员与 AI 助手(如 ChatGPT, Claude, DeepSeek 等)沟通效率的 VS Code 插件。

它可以帮助你快速将项目中的多个文件、文件夹或选中的代码片段,合并成一个格式规范的 Markdown 文件。这让你在向 AI 提问时,能够轻松地提供准确的代码上下文。

✨ 主要功能

  • 批量处理: 支持在资源管理器中选中多个文件或整个文件夹,一键合并为一个 Markdown 文件。
  • 代码片段模式: 支持在编辑器中选中一段代码,仅转换该片段(会自动标注行号范围)。
  • 智能格式化: 自动识别文件后缀,并使用对应的 Markdown 代码块(如 js, php, vue)进行包裹。
  • 上下文保留: 在每个代码块前自动添加文件的相对路径,帮助 AI 理解项目结构。
  • 统一快捷键: 使用一个快捷键 (Ctrl+Shift+Alt+M) 即可处理所有场景。

🚀 使用指南

1. 转换文件或文件夹 (资源管理器模式)

适用于将整个模块或目录结构发给 AI。

  1. 在左侧 资源管理器 (Explorer) 中。
  2. 选中一个或多个文件/文件夹(按住 Ctrl 或 Cmd 可多选)。
  3. 点击鼠标右键,选择菜单项 "将代码转换为 Markdown"。
  4. 或者:选中后直接按下快捷键 Ctrl+Shift+Alt+M。

2. 转换选中的代码片段 (片段模式)

适用于针对特定的函数或逻辑块进行提问。

  1. 在编辑器中打开任意文件。
  2. 鼠标 选中一段代码。
  3. 在编辑器区域点击右键,选择 "将代码转换为 Markdown"。
  4. 或者:选中后直接按下快捷键 Ctrl+Shift+Alt+M。
  5. 注意: 生成的 Markdown 会包含文件路径和具体的行号信息(例如:第 10-25 行)。

3. 转换当前文件 (单文件模式)

快速转换当前正在查看的文件。

  1. 在编辑器中打开文件。
  2. 确保 没有选中任何文字。
  3. 按下快捷键 Ctrl+Shift+Alt+M(或右键点击)。
  4. 当前文件的全部内容将被转换。

⌨️ 快捷键

操作系统 组合键
Windows / Linux Ctrl + Shift + Alt + M
macOS Cmd + Shift + Alt + M

Enjoy coding with your AI assistant!

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft