{"id":17720639,"url":"https://github.com/freed-wu/template.vim","last_synced_at":"2026-02-15T01:05:25.440Z","repository":{"id":93504622,"uuid":"607797326","full_name":"Freed-Wu/template.vim","owner":"Freed-Wu","description":"Powerful template engine/plugin for vim","archived":false,"fork":false,"pushed_at":"2025-11-24T18:48:43.000Z","size":53,"stargazers_count":0,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-28T07:09:19.223Z","etag":null,"topics":["jinja2","template","vim"],"latest_commit_sha":null,"homepage":"https://luarocks.org/modules/Freed-Wu/template.vim","language":"Vim Script","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Freed-Wu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"custom":["https://user-images.githubusercontent.com/32936898/199681341-1c5cfa61-4411-4b67-b268-7cd87c5867bb.png","https://user-images.githubusercontent.com/32936898/199681363-1094a0be-85ca-49cf-a410-19b3d7965120.png","https://user-images.githubusercontent.com/32936898/199681368-c34c2be7-e0d8-43ea-8c2c-d3e865da6aeb.png"]}},"created_at":"2023-02-28T17:39:26.000Z","updated_at":"2024-06-22T02:17:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"eab0774a-07e3-4e02-8fb5-e4819120c5fe","html_url":"https://github.com/Freed-Wu/template.vim","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Freed-Wu/template.vim","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Freed-Wu%2Ftemplate.vim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Freed-Wu%2Ftemplate.vim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Freed-Wu%2Ftemplate.vim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Freed-Wu%2Ftemplate.vim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Freed-Wu","download_url":"https://codeload.github.com/Freed-Wu/template.vim/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Freed-Wu%2Ftemplate.vim/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29463603,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-15T01:01:38.065Z","status":"ssl_error","status_checked_at":"2026-02-15T01:01:23.809Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["jinja2","template","vim"],"created_at":"2024-10-25T15:28:36.768Z","updated_at":"2026-02-15T01:05:25.422Z","avatar_url":"https://github.com/Freed-Wu.png","language":"Vim Script","funding_links":["https://user-images.githubusercontent.com/32936898/199681341-1c5cfa61-4411-4b67-b268-7cd87c5867bb.png","https://user-images.githubusercontent.com/32936898/199681363-1094a0be-85ca-49cf-a410-19b3d7965120.png","https://user-images.githubusercontent.com/32936898/199681368-c34c2be7-e0d8-43ea-8c2c-d3e865da6aeb.png"],"categories":[],"sub_categories":[],"readme":"# template.vim\n\n[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/Freed-Wu/template.vim/main.svg)](https://results.pre-commit.ci/latest/github/Freed-Wu/template.vim/main)\n[![github/workflow](https://github.com/Freed-Wu/template.vim/actions/workflows/main.yml/badge.svg)](https://github.com/Freed-Wu/template.vim/actions)\n\n[![github/downloads](https://shields.io/github/downloads/Freed-Wu/template.vim/total)](https://github.com/Freed-Wu/template.vim/releases)\n[![github/downloads/latest](https://shields.io/github/downloads/Freed-Wu/template.vim/latest/total)](https://github.com/Freed-Wu/template.vim/releases/latest)\n[![github/issues](https://shields.io/github/issues/Freed-Wu/template.vim)](https://github.com/Freed-Wu/template.vim/issues)\n[![github/issues-closed](https://shields.io/github/issues-closed/Freed-Wu/template.vim)](https://github.com/Freed-Wu/template.vim/issues?q=is%3Aissue+is%3Aclosed)\n[![github/issues-pr](https://shields.io/github/issues-pr/Freed-Wu/template.vim)](https://github.com/Freed-Wu/template.vim/pulls)\n[![github/issues-pr-closed](https://shields.io/github/issues-pr-closed/Freed-Wu/template.vim)](https://github.com/Freed-Wu/template.vim/pulls?q=is%3Apr+is%3Aclosed)\n[![github/discussions](https://shields.io/github/discussions/Freed-Wu/template.vim)](https://github.com/Freed-Wu/template.vim/discussions)\n[![github/milestones](https://shields.io/github/milestones/all/Freed-Wu/template.vim)](https://github.com/Freed-Wu/template.vim/milestones)\n[![github/forks](https://shields.io/github/forks/Freed-Wu/template.vim)](https://github.com/Freed-Wu/template.vim/network/members)\n[![github/stars](https://shields.io/github/stars/Freed-Wu/template.vim)](https://github.com/Freed-Wu/template.vim/stargazers)\n[![github/watchers](https://shields.io/github/watchers/Freed-Wu/template.vim)](https://github.com/Freed-Wu/template.vim/watchers)\n[![github/contributors](https://shields.io/github/contributors/Freed-Wu/template.vim)](https://github.com/Freed-Wu/template.vim/graphs/contributors)\n[![github/commit-activity](https://shields.io/github/commit-activity/w/Freed-Wu/template.vim)](https://github.com/Freed-Wu/template.vim/graphs/commit-activity)\n[![github/last-commit](https://shields.io/github/last-commit/Freed-Wu/template.vim)](https://github.com/Freed-Wu/template.vim/commits)\n[![github/release-date](https://shields.io/github/release-date/Freed-Wu/template.vim)](https://github.com/Freed-Wu/template.vim/releases/latest)\n\n[![github/license](https://shields.io/github/license/Freed-Wu/template.vim)](https://github.com/Freed-Wu/template.vim/blob/main/LICENSE)\n[![github/languages](https://shields.io/github/languages/count/Freed-Wu/template.vim)](https://github.com/Freed-Wu/template.vim)\n[![github/languages/top](https://shields.io/github/languages/top/Freed-Wu/template.vim)](https://github.com/Freed-Wu/template.vim)\n[![github/directory-file-count](https://shields.io/github/directory-file-count/Freed-Wu/template.vim)](https://github.com/Freed-Wu/template.vim)\n[![github/code-size](https://shields.io/github/languages/code-size/Freed-Wu/template.vim)](https://github.com/Freed-Wu/template.vim)\n[![github/repo-size](https://shields.io/github/repo-size/Freed-Wu/template.vim)](https://github.com/Freed-Wu/template.vim)\n[![github/v](https://shields.io/github/v/release/Freed-Wu/template.vim)](https://github.com/Freed-Wu/template.vim)\n\n[![luarocks](https://img.shields.io/luarocks/v/Freed-Wu/template.vim)](https://luarocks.org/modules/Freed-Wu/template.vim)\n\nPowerful template engine/plugin for vim.\n\nTemplate `%.c`, which syntax looks like a subset of\n[jinja2](https://github.com/pallets/jinja/).\n\n```jinja2\n/*\n * {{ expand('%:t') }}\n * Copyright (C) {{ strftime('%Y') }} {{ g:snips_author }} \u003c{{ g:snips_email }}\u003e\n *\n * Distributed under terms of the GPL3 license.\n */\n{# comment #}\n#if {{ len([]) }}\n#include \"{{ expand('%:t:r:r') }}.h\"{% here %}\n#endif\n#include \u003cstdio.h\u003e\n  {#-comment, strip left whitespaces #}int\n  {#-comment, strip around whitespaces-#}  main(int argc, char *argv[])\n{\n  printf(\"'\\{\\{ string \\}\\}' is %s\", \"not variable\");\n  printf(\"'\\{\\# string \\#\\}' is %s\", \"not comment\");\n  printf(\"'\\{\\%% string %\\%\\}' is %s\", \"not directive\");\n  {# comment, strip right whitespaces-#}  return {{ 1 - 1 }};\n}\n```\n\n```bash\n# Use vim to create a file `test.c` (match the regular expression `\\.c$`)\nvi test.vim\n```\n\nYou got\n\n```c\n/*\n * test.c.bak\n * Copyright (C) 2023 Freed \u003cFreed@mail.com\u003e\n *\n * Distributed under terms of the GPL3 license.\n */\n\n#if 0\n#include \"test.h\"\n#endif\n#include \u003cstdio.h\u003e\nint\nmain(int argc, char *argv[])\n{\n  printf(\"'{{ string }}' is %s\", \"not variable\");\n  printf(\"'{# string #}' is %s\", \"not comment\");\n  printf(\"'{%% string %%}' is %s\", \"not directive\");\n  return 0;\n}\n```\n\nYour cursor stays in `{% here %}`.\n\nYour `.vimrc`. The variable names come from\n[vim-snippets](https://github.com/honza/vim-snippets/blob/master/plugin/vimsnippets.vim).\n\n```vim\nlet g:snips_author = 'Freed'\nlet g:snips_email = 'Freed@mail.com'\n```\n\nSyntax highlight is provided:\n\n![syntax highlight](https://github.com/Freed-Wu/template.vim/assets/32936898/dc49ec2e-776a-4ccc-9329-d6b1bee7916f)\n\n## Similar projects\n\n### Vim Template Plugins\n\n- [aperezdc/vim-template](https://github.com/aperezdc/vim-template) converts\n  `%USER%`, `%MAIL`, `%FILE%`, `%YEAR%`, ...\n- [tibabit/vim-templates](https://github.com/tibabit/vim-templates) converts\n  `{{NAME}}`, `{{EMAIL}}`, `{{FILE}}`, `{{YEAR}}`, ...\n\nThis plugin doesn't provide any mark. You should use your vim script knowledge\nto get what you want:\n\n\u003c!-- markdownlint-disable MD013 --\u003e\n\n1. define some global variables in your `.vimrc` to store those invariable\n   data. Such as your name, email, ...\n2. use `expand('%:XXX')` to get any thing about file path. You can make it\n   enough complex. Such as you can get perl module name `Foo::Bar::Baz` in\n   [`foo-bar-baz/Makefile.PL`](https://metacpan.org/pod/ExtUtils::MakeMaker) by\n   `{{ substitute(substitute(expand('%:p:h:t'), '\\%(-\\|^\\)\\(.\\)', '::\\u\\1', 'g'), '^::', '', 'g') }}`\n   If you think it is too long, you can define a global function in your\n   `.vimrc`, then simply call it.\n3. use `strftime()` to get any thing about date and time.\n4. use `system()` to get any thing about your OS. Such as, when you report bug\n   to a vim plugin, you should provide the basic information of your platforms:\n   Your OS version, your vim version. If this plugin is written in python,\n   ruby, perl, js or any other languages except vim script, you should provide\n   your python version or any other language's version, too. A `test.vim` for\n   this propose looks like:\n\n```vim\n#!/usr/bin/env -S vi -u\n\" $ uname -r\n\" {{ trim(system('uname -r')) }} {#-OS version #}\n\" $ vi --version | head -n1\n\" {{ join(split(execute('version'))[0:1]) }}\n{#-vim version can be gotten form `:version` which is faster than `system()`-#}\n\" $ python --version\n\" {{ trim(system('python --version')) }}\n\" $ cat test.vim\nset runtimepath=$VIMRUNTIME\nset runtimepath+=~/.local/share/nvim/repos/github.com/{% here %}\n\" rest configuration in vim\n\" $ chmod +x test.vim\n\" $ ./test.vim\n\" press some keys or input some commands\n\" Expected behaviour: work normally\n\" Actual behaviour: broken, the error information is:\n\" segmentation fault\n```\n\nBTW, if you change from other vim template plugins, you can do the following\nworks to convert your template formats to let this plugin support them:\n\n```sh\n# change marks\nperl -pi -e\"s/%DATE%/{{ strftime('%F') }}/g\" *\nperl-rename 's/^=template=\\./%/' *\nperl-rename 's/$/%24/' *\n```\n\n## Usage\n\n[`:help template`](doc/template.txt)\n\n## Install\n\n### From Package Manager\n\nSee `:help 'your package manager'`.\n\n### From Source\n\nDownload and extract it to `\u0026runtimepath` (See `:help 'runtimepath'`).\n\n## Other Resources\n\n### Tools\n\n- [kana/vim-smartinput](https://github.com/kana/vim-smartinput/): input `{`\n  will get `{|}`, `|` is cursor, then input `%` will get `{%|%}` or input `#`\n  will get `{#|#}`. Input `\u003cSpace\u003e` will get `{% | %}`, `{# | #}`, ... See\n  [my configuration of this\n  plugin](https://github.com/Freed-Wu/my-dotfiles/blob/main/.config/nvim/autoload/init/smartinput.vim).\n- [sheerun/vim-polyglot](https://github.com/sheerun/vim-polyglot) contains jinja2\n  syntax highlight.\n- [My templates for this plugin](https://github.com/Freed-Wu/my-dotfiles/tree/main/.config/nvim/templates)\n\n### Develop\n\nThis plugin use the following tools to develop (you don't need to install\nthem if you only want to use this plugin):\n\n- [google/vimdoc](https://github.com/google/vimdoc) A tool to generate vim\n  document from comment.\n- [vim-jp/vital.vim](https://github.com/vim-jp/vital.vim) A library of vim\n  script.\n- [thinca/vim-themis](https://github.com/thinca/vim-themis) Unit test framework\n  for vim script.\n- [Other many tools](https://github.com/Freed-Wu/template.vim/tree/master/.pre-commit-config.yaml)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffreed-wu%2Ftemplate.vim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffreed-wu%2Ftemplate.vim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffreed-wu%2Ftemplate.vim/lists"}