Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>File Templates ProNew to Visual Studio Code? Get it now.
File Templates Pro

File Templates Pro

firma

|
1 install
| (0) | Free
A VSCode extension for file templates and project scaffolding. Auto-generate file headers and project structures with customizable templates.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

File Templates Pro

English | 中文


English

A high-performance VS Code extension for fully customizable file templates and project scaffolding.

Features

  • Fully Customizable: Define your own templates with glob patterns, variables, and default values
  • High Performance: Optimized with caching, pre-compiled regex, and efficient algorithms
  • Project Scaffolding: Generate complete project structures with nested directories
  • Smart Variable Resolution: Built-in variables, user constants, and interactive prompts

Usage

  1. Open File Templates Pro from the activity bar
  2. Click the Settings button to open the configuration panel
  3. Add your constants, file templates, and scaffolds in the beautiful webview UI
  4. Create new files - templates are automatically applied
  5. Use scaffolds to generate project structures

Scaffold List

Configuration

All configuration is done through the webview interface:

  1. Click the File Templates Pro icon in the activity bar
  2. Click the Settings button (⚙️)
  3. Configure in the intuitive interface:
    • Constants: Reusable values for all templates
    • File Templates: Patterns and content for new files
    • Scaffolds: Complete project structures

Settings Panel

Constants Configuration

File Templates Configuration

Project Scaffolds

Click the Generate button to generate the scaffold in the workspace root directory, or click Generate At to select a custom target folder.

Node.js Project (ES Modules)

js-project/
├── package.json        # ES modules, modern scripts
├── src/
│   └── index.js        # Entry point
├── .gitignore
└── README.md

C++ Project (C++20 + CMake)

cpp-project/
├── CMakeLists.txt      # Modern CMake (3.20+), C++20
├── src/
│   └── main.cpp        # std::format, modern C++
├── .clang-format       # Google style
├── .clangd             # clangd config with ClangTidy
├── .gitignore
└── README.md

Python Project (pyproject.toml)

py-project/
├── pyproject.toml      # PEP 517/518, setuptools backend
├── src/
│   └── {package}/
│       ├── __init__.py
│       └── main.py     # Entry point
├── tests/
│   ├── __init__.py
│   └── test_main.py    # pytest tests
├── .gitignore
└── README.md

How It Works

Variable Resolution Priority

When a template contains {{variable}}, the extension resolves it in this order:

  1. Built-in Variables → Auto-filled (e.g., {{year}}, {{filename}})
  2. User Constants → Defined in settings, reused across all templates
  3. Default Value → If {{var:default}} syntax is used
  4. Interactive Prompt → User is asked to input the value

Example

Template configuration:

{
  "*.py": "# {{filename}} - Created by {{author}} for {{project}} on {{year}}-{{month}}-{{day}}\n\n"
}

User constants:

{
  "author": "Alice"
}

When creating utils.py: | Variable | Resolution | Value | |----------|------------|-------| | {{filename}} | Built-in | utils | | {{author}} | User constant | Alice | | {{project}} | Not found → Prompt user | (user types: MyApp) | | {{year}} | Built-in | 2025 | | {{month}} | Built-in | 03 | | {{day}} | Built-in | 11 |

Result:

# utils - Created by Alice for MyApp on 2025-03-11

Built-in Variables

Variable Description Example
filename File name without extension utils
year Current year 2025
month Current month (01-12) 03
day Current day (01-31) 11
hour Current hour (00-23) 14
minute Current minute (00-59) 30
second Current second (00-59) 45
weekday Day of week (1-7, Mon=1) 3

Template Syntax

{{variable}}           // Required - prompts user if not found
{{variable:default}}   // Optional - uses default value if not found

中文

一款高性能、完全可定制的 VS Code 文件模板和项目脚手架扩展。

功能特性

  • 完全可定制:使用 glob 模式、变量和默认值定义模板
  • 高性能:缓存优化、预编译正则、高效算法
  • 项目脚手架:生成完整的嵌套目录项目结构
  • 智能变量解析:内置变量、用户常量、交互式输入

使用方法

  1. 从活动栏打开 File Templates Pro
  2. 点击 Settings 按钮打开配置面板
  3. 在漂亮的 webview 界面中配置常量、文件模板和脚手架
  4. 创建新文件 - 模板自动应用
  5. 使用脚手架生成项目结构

脚手架列表

配置

所有配置都通过 webview 界面完成:

  1. 点击活动栏中的 File Templates Pro 图标
  2. 点击 Settings 按钮 (⚙️)
  3. 在直观的界面中配置:
    • Constants:所有模板可复用的值
    • File Templates:新文件的匹配模式和内容
    • Scaffolds:完整的项目结构

设置面板

常量配置

文件模板配置

项目脚手架

点击 Generate 按钮在工作区根目录生成脚手架,或点击 Generate At 选择自定义目标文件夹。

Node.js 项目 (ES Modules)

js-project/
├── package.json        # ES modules, 现代脚本
├── src/
│   └── index.js        # 入口文件
├── .gitignore
└── README.md

C++ 项目 (C++20 + CMake)

cpp-project/
├── CMakeLists.txt      # 现代 CMake (3.20+), C++20
├── src/
│   └── main.cpp        # std::format, 现代 C++
├── .clang-format       # Google 风格
├── .clangd             # clangd 配置, 包含 ClangTidy
├── .gitignore
└── README.md

Python 项目 (pyproject.toml)

py-project/
├── pyproject.toml      # PEP 517/518, setuptools 后端
├── src/
│   └── {package}/
│       ├── __init__.py
│       └── main.py     # 入口文件
├── tests/
│   ├── __init__.py
│   └── test_main.py    # pytest 测试
├── .gitignore
└── README.md

工作原理

变量解析优先级

当模板包含 {{variable}} 时,扩展按以下顺序解析:

  1. 内置变量 → 自动填充(如 {{year}}、{{filename}})
  2. 用户常量 → 在设置中定义,所有模板复用
  3. 默认值 → 如果使用 {{var:default}} 语法
  4. 交互式输入 → 提示用户输入

示例

模板配置:

{
  "*.py": "# {{filename}} - Created by {{author}} for {{project}} on {{year}}-{{month}}-{{day}}\n\n"
}

用户常量:

{
  "author": "Alice"
}

创建 utils.py 时: | 变量 | 解析来源 | 值 | |------|----------|-----| | {{filename}} | 内置变量 | utils | | {{author}} | 用户常量 | Alice | | {{project}} | 未找到 → 提示用户输入 | (用户输入: MyApp) | | {{year}} | 内置变量 | 2025 | | {{month}} | 内置变量 | 03 | | {{day}} | 内置变量 | 11 |

结果:

# utils - Created by Alice for MyApp on 2025-03-11

内置变量

变量 描述 示例
filename 文件名(不含扩展名) utils
year 当前年份 2025
month 当前月份 (01-12) 03
day 当前日期 (01-31) 11
hour 当前小时 (00-23) 14
minute 当前分钟 (00-59) 30
second 当前秒数 (00-59) 45
weekday 星期几 (1-7, 周一=1) 3

模板语法

{{variable}}           // 必填 - 未找到时提示用户输入
{{variable:default}}   // 可选 - 未找到时使用默认值

License

MIT License

Author

Created by kiki

Enjoy!

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