Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Czo TemplateNew to Visual Studio Code? Get it now.
Czo Template

Czo Template

czo64

|
8 installs
| (0) | Free
Inserts file header templates and keeps them up to date on every save
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Czo Template

Inserts file header templates and keeps them up to date on every save.

/*
 * Filename: main.c
 * Author: John Doe <john.doe@mail.org>
 * License: GPL-2.0 (http://www.gnu.org/copyleft)
 * File Created: 07 March 2026
 * Last Modified: Friday 03 April 2026, 19:46
 * Edit Time: 5:44:02
 * Description:
 *
 *                  my c program
 *
 * Copyright: (C) 2026 John Doe <john.doe@mail.org>
 */

The Filename:, Author:, License:, File Created:, Last Modified:, Edit Time: and Copyright: fields are updated automatically on every save.

Features

  • Insert a language-appropriate header template at the top of any file
  • Auto-update header fields every time you save
  • Track cumulative editing time per file
  • User-defined regexp substitutions with macro tokens
  • Fully customizable templates per language
  • Legacy field renaming for compatibility with older headers

Commands

Command Description
Czo Template: Enable Enable the extension
Czo Template: Disable Disable the extension
Czo Template: Insert Template Insert a header for the current language
Czo Template: Insert Template For languageId... Insert a header for a chosen language
Czo Template: Update Update header fields without saving

Keyboard Shortcuts

Shortcut Command
Ctrl+Alt+H Ctrl+Alt+H Czo Template: Insert Template
Ctrl+Alt+H Ctrl+Alt+U Czo Template: Update

Configuration

All settings live in settings.json (user or workspace level).

Setting Description
czoTemplate.enabled Enable or disable the extension
czoTemplate.autoUpdateEveryFile Allow updates on files without a recognized template
czoTemplate.maxHeaderLines Number of lines scanned for header fields
czoTemplate.author Author name and email
czoTemplate.license License string
czoTemplate.shortdate strftime format for File Created:
czoTemplate.longdate strftime format for Last Modified:
czoTemplate.templates Custom template overrides (see below)
czoTemplate.regexps User-defined regexp substitutions (see below)

These are the defaults:

{
    "czoTemplate.enabled": true,
    "czoTemplate.autoUpdateEveryFile": false,
    "czoTemplate.maxHeaderLines": 50,
    "czoTemplate.author": "John Doe <john.doe@mail.org>",
    "czoTemplate.license": "GPL-2.0 (http://www.gnu.org/copyleft)",
    "czoTemplate.shortdate": "%d %B %Y",
    "czoTemplate.longdate": "%A %d %B %Y, %H:%M"
}

Supported languages

Built-in templates are provided for:

c, cpp, crontab, css, h, hpp, html, java, javascript, json, lua, makefile, markdown, perl, php, python, shellscript, typescript

Any other VS Code languageId can be supported by adding a custom template (see Custom templates).

Auto-update on save

Every time you save, any of the following fields found in the first czoTemplate.maxHeaderLines lines are updated:

Field Action
Filename: Current filename (basename)
FullFilename: Full path of the file
Author: Value of czoTemplate.author
License: Value of czoTemplate.license
File Created: Set once with czoTemplate.shortdate format (only if no year is present)
Last Modified: Current date/time with czoTemplate.longdate format
Edit Time: Cumulative editing time since the file was opened
Copyright: (C) [year range] czoTemplate.author

Updates for unsupported file types

By default, updates only work on files with a recognized template. To enable updates on any file type, enable czoTemplate.autoUpdateEveryFile. This is useful if you have custom header patterns in files without a built-in template.

With autoUpdateEveryFile: false (default):

  • Updates only work on files with a recognized template

With autoUpdateEveryFile: true:

  • All header fields (Filename, Last Modified, Edit Time, etc.) will be updated for any file

User-defined regexps will still be applied to all files regardless of this setting

Legacy field renaming

For compatibility with older .vimrc headers, these fields are automatically renamed:

Old field Renamed to
Started: File Created:
Created: File Created:
Last Change: Last Modified:

Custom templates

Override any built-in template or create new ones via czoTemplate.templates. Each key is a template name (file extension like c, sh, pl, or a VS Code languageId like javascript, perl). The value is an array of strings, one per line.

"czoTemplate.templates": {
    "c": [
        "/*",
        " * Filename:",
        " * Author:",
        " * License:",
        " * File Created:",
        " * Last Modified:",
        " * Edit Time:",
        " * Description:",
        " *",
        " * Copyright:",
        " */"
    ],
    "perl": [
        "#! /usr/bin/env perl",
        "#",
        "# Filename:",
        "# Author:",
        "# License:",
        "# File Created:",
        "# Last Modified:",
        "# Edit Time:",
        "# Description:",
        "#",
        "# Copyright:"
    ]
}

Template resolution order

  1. czoTemplate.templates.<languageId> in settings.json
  2. czoTemplate.templates.<fileExt> in settings.json
  3. Built-in template <extensionPath>/out/templates/template.<fileExt>

Custom regexp substitutions

Define your own regexp substitutions applied to the entire document on every save or update via czoTemplate.regexps.

Each entry has:

Field Description
find JavaScript regexp string (without /…/ delimiters)
replace Replacement string — supports $1, $2, … capture groups and macro tokens
mode Optional flags: i (case-insensitive), g (global)

Note: m and s flags have no effect as regexps are applied line by line.

"czoTemplate.regexps": [
    {
        // substitute CVS $Id: because I'm now using Git and I need an
        // identifier ($Id) from my old CVS scripts...
        "find": "(\\$Id\\:).*( czo Git \\$)",
        "replace": "$1 <<FILENAME>>,v 1.42 <<STRFTIME=\"%Y/%m/%d %T\">>$2"
    },
    {
        // substitute ( Czo\Date: ) by ( Czo\Date: 2024-03-14 14:36 )
        "find": "(\\( Czo\\Date:)\\s*[\\d :+-]*\\s*\\)",
        "replace": "$1 <<STRFTIME=\"%F %R\">> )"
    }
]

Tip: To avoid a pattern matching itself in settings.json on save, break the literal string with an escaped character, e.g. "\\$Id\\:" matches $Id: in files but the string \\$Id\\: in settings.json does not match itself.

Macro tokens

The following tokens are expanded in the replace string before the regexp is applied:

Token Value
<<STRFTIME="%fmt">> Date/time formatted with strftime (e.g. <<STRFTIME="%Y/%m/%d %T">>)
<<FILENAME>> Current filename (basename only, e.g. foo.c)
<<FULLFILENAME>> Full path of the current file
<<HOME>> Home directory ($HOME or %USERPROFILE%)
<<USER>> Current user ($USER or %USERNAME%)
<<HOSTNAME>> Hostname ($HOSTNAME)

License

Released under the GPL-2.0 License.

Port of template.vim by Olivier Sirol (czo@free.fr) — see my .vimrc.

Copyright (C) 2026 Olivier Sirol czo@free.fr

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