Home

Awesome

Project Templates VSCode Extension

Visual Studio code extension that allows you to quickly create new projects based on custom templates.

Inspired by this File Templates Extension, which is itself inspired by a similar Atom Extension.

Features

demo

Install

In Visual Studio code, Press F1 to open the command menu and type ext install cantonios.project-templates.

Extension Settings

This extension contributes the following settings:

{
  "projectTemplates.templatesDirectory": "",          // default directory containing project templates
  "projectTemplates.usePlaceholders": true,           // activate placeholder substitution
  "projectTemplates.placeholders": {  },              // dictionary of default placeholder key-value pairs
  "projectTemplates.placeholderRegExp": "#{(\\w+?)}"  // regular expression to use for detecting placeholders
}

Known Issues

Release Notes

See CHANGELOG for release notes.

Usage

Extension commands can be executed from the Command Palette or from the context menu when selecting a folder.

<img src="https://raw.githubusercontent.com/cantonios/vscode-project-templates/master/images/commands.png" width="450" /> <img src="https://raw.githubusercontent.com/cantonios/vscode-project-templates/master/images/menu.png" width="250" />

Creating a Project from a Template

Saving a Project as a Template

Placeholders

Variable placeholders can be used in templates in the following way:

Author: #{author}
Title:  #{title}

When a file is created from a template containing placeholders, the user is prompted for a value to enter. Placeholders can also be used in filenames.

Templates Location

By default, this extension expects the project templates to be placed within the user's data directory for VSCode, which is OS-specific. For the non-portable version of VSCode, this is typically

$HOME/.config/Code/User/ProjectTemplates                       # Linux
$HOME/Library/Application Support/Code/User/ProjectTemplates   # macOS
%APPDATA%\Code\User\ProjectTemplates                           # Windows

For the portable version of vscode, or if a --user-data-dir is specified at the command-line, the default template location is

$USER_DATA_DIR/User/ProjectTemplates

You can change the templates location by adding the following to your user or workspace settings:

"projectTemplates.templatesDirectory": "path/to/my/templates"

This path supports VSCode's predefined variables, such as ${env:HOME}.

Samples

A set of sample templates can be found here