{"id":13898298,"url":"https://github.com/LucHermitte/mu-template","last_synced_at":"2025-07-17T15:33:00.063Z","repository":{"id":28635919,"uuid":"32154833","full_name":"LucHermitte/mu-template","owner":"LucHermitte","description":"Vim template-files expander","archived":false,"fork":false,"pushed_at":"2025-02-28T17:48:16.000Z","size":831,"stargazers_count":19,"open_issues_count":4,"forks_count":1,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-02-28T21:59:28.701Z","etag":null,"topics":["skeleton-template","snippets","vim","vim-plugins"],"latest_commit_sha":null,"homepage":"","language":"Vim Script","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LucHermitte.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"License.md","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}},"created_at":"2015-03-13T12:34:03.000Z","updated_at":"2025-02-28T17:48:20.000Z","dependencies_parsed_at":"2025-01-24T11:36:59.195Z","dependency_job_id":null,"html_url":"https://github.com/LucHermitte/mu-template","commit_stats":null,"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"purl":"pkg:github/LucHermitte/mu-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LucHermitte%2Fmu-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LucHermitte%2Fmu-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LucHermitte%2Fmu-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LucHermitte%2Fmu-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LucHermitte","download_url":"https://codeload.github.com/LucHermitte/mu-template/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LucHermitte%2Fmu-template/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265622797,"owners_count":23800039,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["skeleton-template","snippets","vim","vim-plugins"],"created_at":"2024-08-06T18:04:13.095Z","updated_at":"2025-07-17T15:32:59.667Z","avatar_url":"https://github.com/LucHermitte.png","language":"Vim Script","funding_links":[],"categories":["Vim Script"],"sub_categories":[],"readme":"# µTemplate [![Last release][Releases-badge]][Releases-url] [![Build Status][gh-action-badge]][gh-action-result] [![Project Stats][openhub-badge]][openhub-url]\n\n[Releases-badge]:   https://img.shields.io/github/tag/LucHermitte/mu-template.svg\n[Releases-url]:     https://github.com/LucHermitte/mu-template/tags\n[gh-action-badge]:  ./../../actions/workflows/tests.yml/badge.svg?branch=master \"Test\"\n[gh-action-result]: ./../../actions/workflows/tests.yml?query=branch%3Amaster\n[openhub-badge]:    https://www.openhub.net/p/21020/widgets/project_thin_badge.gif\n[openhub-url]:      https://www.openhub.net/p/21020\n\n## Introduction\n\nµTemplate is a template-files loader for Vim. Once loaded, templates are interpreted and expanded according to a flexible syntax.\n\n  * [Features](#features)\n  * [Typical workflows](doc/workflows.md)\n    * [Plugin Configuration](doc/workflows.md#plugin-configuration)\n    * [Snippet Expansion](doc/workflows.md#snippet-expansion)\n    * [Surrounding with a snippet](doc/workflows.md#surrounding-with-a-snippet)\n    * [Filetype dependent templates for new files](doc/workflows.md#filetype-dependent-templates-for-new-files)\n  * [Shipped templates](doc/shipped_templates.md)\n    * [Vim](doc/shipped_templates.md#vim)\n    * [Python](doc/shipped_templates.md#python)\n    * [C \u0026 C++](doc/shipped_templates.md#c--c)\n    * [LaTeX](doc/shipped_templates.md#latex)\n    * [XSLT](doc/shipped_templates.md#xslt)\n    * [Licenses](doc/shipped_templates.md#licenses)\n    * [Other filetypes](doc/shipped_templates.md#other-filetypes)\n  * [Examples](#examples)\n    * [C-`if` snippet](#c-if-snippet)\n    * [C-`case` snippet](#c-case-snippet)\n    * [Interactive template-file: C++ Class Template](#interactive-template-file:-c++-class-template)\n    * [Completely useless recursive example](#completely-useless-recursive-example)\n  * [Installation](#installation)\n  * [Credits](#credits)\n  * [See also](#see-also)\n\n\n## Features\n  * Template-files can be expanded:\n    * automatically when opening a new buffer (unless deactivated from the .vimrc),\n    * explicitly through menus or the command line,\n    * from the INSERT-mode in a snippet-like fashion ;\n    * from the VISUAL-mode to surround the selection with a snippet ;\n  * All snippets are defined in their own template-file ;\n  * The template-files can be overridden by the user, or in the context of a specific project ;\n  * Filetype specific snippets can be defined for the INSERT-mode (they can be inherited, e.g. C snippets can be used from C++, Java, _etc._), the list of matching snippets will be presented with a hint for each snippet ;\n  * Computed VimL expressions can be inserted ;\n  * VimL instructions can be executed during the expansion ;\n  * Template-files can include other template-files in a function-like manner (parameters are even supported);\n  * Fully integrated with my [placeholders-system](http://github.com/LucHermitte/lh-brackets) ;\n  * Supports re-indentation (if desired), and Python indentation ;\n  * Works well with vim folding ;\n  * I18n friendly ;\n  * The expansion happens after any [_local vimrcs_](http://github.com/LucHermitte/local_vimrc) present are loaded -- in order to set project-specific variables before the expansion is done.\n\n  * Thanks to [Tom Link's StakeHolders](http://www.vim.org/scripts/script.php?script_id=3326) plugin, µTemplate does now have tied placeholders (modifying one named placeholder modifies other placeholders with the same name). Not installing Stakeholders will not prevent you from using µTemplate.\n\nHowever, it misses the following features:\n  * Several snippets per template-file -- It's extremely unlikely that µTemplate will ever work this way.\n  * One key that does everything: expansion of snippets/previously typed keywords/dictionary/..., or jump to the next placeholder depending on the context.\n\n## Examples\n\nA few examples are better than a long speech, check the [documentation](doc/mu-template.txt) for more precisions.\n\nNote: all the default template-files shipped with mu-template can be browsed from the [repository](after/template/)\n\n### C-`if` snippet\nSnippet that uses `¡`, `s:Surround()`, [lh-style's styling feature](http://github.com/LucHermitte/lh-style#formatting.of.brackets.characters)\n```\nVimL:\"{if} Template-File, Luc Hermitte\nVimL:\" hint: if (cond) { action }\nVimL: let s:value_start = '¡'\nVimL: let s:value_end = '¡'\nVimL: let s:reindent = 1\nVimL: let s:marker_open = '\u003c+'\nVimL: let s:marker_close = '+\u003e'\nif(¡substitute(s:Surround(2, '\u003c+cond+\u003e'), '^\\_s*\\|\\_s*$', '', 'g')¡){\n¡s:Surround(1, '\u003c+code+\u003e')¡\n}\u003c+s:TerminalPlaceHolder()+\u003e\n```\n\n### C-`case` snippet\nSnippet that uses `¡`, `s:TerminalPlaceHolder()`, [lh-style's styling feature](http://github.com/LucHermitte/lh-style#formatting.of.brackets.characters), and that takes options.\n```\nVimL:\" {case:} File Template, Luc Hermitte, 05th Jan 2011\nVimL:\" hint: case {tag: ...; break;}\nVimL: let s:value_start = '¡'\nVimL: let s:value_start = '¡'\nVimL: let s:value_end = s:value_start\nVimL: let s:marker_open = '\u003c+'\nVimL: let s:marker_close = '+\u003e'\nVimL: let s:case = empty(s:Args()) ? lh#marker#txt('case') : (s:Args()[0])\nVimL: let s:_with_block2 = len(s:Args()) \u003c= 1 ? INPUT(\"Insert a block for the case (0/1) ?\") : (s:Args()[1])\ncase \u003c+s:case+\u003e:\n\u003c+s:_with_block2?'{':''+\u003e\n\u003c+¡substitute(s:case, lh#marker#txt('\\(.\\{-}\\)'), '\\1', '')¡-code+\u003e;\nbreak;\n\u003c+s:_with_block2?'}':''+\u003e\n```\n\n### Vim-`plugmap` snippet\nRecursive snippet that takes options, uses `s:Include()`,\n`s:SurroundableParam()`, `:MuT`-commands, and that contain a loop\n\n```\nVimL:\" ``VimL \u003cPlug\u003e mappings'' File Template, Luc Hermitte \u003chermitte {at} free {dot} fr\u003e\nVimL:\" hint: \u003cPlug\u003emapping + default mapping\nVimL: let s:reindent     = 1\nVimL: let s:marker_open  = '\u003c+'\nVimL: let s:marker_close = '+\u003e'\nMuT:  let s:mapmode = s:SurroundableParam('mode', 1, lh#option#unset())\nMuT:  let s:plugname = s:SurroundableParam('plug', 2, lh#option#unset())\nMuT:  if lh#option#is_unset(s:mapmode)\nMuT:    let s:mapmode = INPUT('Mode (invox)?', lh#marker#txt('mode'))\nMuT:  endif\nMuT:  if lh#option#is_unset(s:plugname)\nMuT:    let s:plugname =  INPUT('\u003cPlug\u003e?',       lh#marker#txt('name'))\nMuT:  endif\nVimL: call s:Include('get-script-kind', 'vim/internals')\nVimL: let s:buffer = s:ftplug ? '\u003cbuffer\u003e ' : ''\nMuT:  if strlen(s:mapmode) == 1 || lh#marker#is_a_marker(s:mapmode)\n\u003c+s:mapmode+\u003enoremap \u003c+s:buffer+\u003e\u003csilent\u003e \u003cPlug\u003e\u003c+s:plugname+\u003e \u003c+definition+\u003e\nif !hasmapto('\u003cPlug\u003e\u003c+s:plugname+\u003e', '\u003c+s:mapmode+\u003e')\n  \u003c+s:mapmode+\u003emap \u003c+s:buffer+\u003e\u003csilent\u003e \u003cunique\u003e \u003c+keybinding+\u003e \u003cPlug\u003e\u003c+s:plugname+\u003e\nendif\nMuT:  else\nVimL:    for mode in split(s:mapmode, '\\zs') | call s:Include('plugmap', 'vim', {'mode': mode, 'plug': s:plugname}) | endfor\nMuT:  endif\n```\n\n### Interactive template-file: C++ Class Template\n```\nVimL:\" C++ Class Template, Luc Hermitte\nVimL:\" hint: Class Wizard (asks for class semantics)\nVimL: let s:value_start = '¡'\nVimL: let s:value_end = '¡'\nVimL: let s:reindent = 1\nVimL: let s:marker_open = '\u003c+'\nVimL: let s:marker_close = '+\u003e'\nVimL: let s:clsname = empty(s:Args()) ? INPUT(\"class name ?\", lh#marker#txt(expand('%:t:r'))) : (s:Args()[0])\nVimL: call CppDox_ClassWizard(s:clsname)\nVimL:\"\nVimL:\"\nVimL: call s:Include(\"section-sep\", \"c\", s:clsname.\" class\")\nVimL: silent! unlet s:doc\nVimL: let s:doc = []\nVimL: let s:doc += [{ \"tag\": \"ingroup\", \"text\": \"g\".lh#option#get('dox_group', lh#marker#txt('Group')) }]\nVimL: let s:doc += [{ \"tag\": \"brief\" }]\nVimL: let s:doc += [{ \"text\": \"\\n\" }]\nVimL: let s:doc += [{ \"text\": \"\u003c+doc+\u003e\" }]\nVimL: let s:doc += [{ \"text\": \"\\n\" }]\nVimL: let s:doc += [{ \"tag\": \"invariant\"}]\nVimL: let s:doc += [{ \"text\": \"\\n\" }]\nVimL: let s:doc += [{ \"tag\": \"semantics\"}]\nVimL: let s:doc += [{ \"text\": g:CppDox_semantics}]\nVimL: let s:doc += [{ \"text\": \"\\n\" }]\nVimL: let s:doc += [{ \"tag\": \"version\", \"text\": \"$\".\"revision$\"}]\nVimL: let s:doc += [{ \"tag\": \"author\"}]\nVimL: call s:Include(\"formatted-comment\", \"cpp/internals\", s:doc)\nclass \u003c+s:clsname+\u003e\n¡g:CppDox_inherits¡\n{\npublic:\n/**\u003c+lh#dox#tag('name')+\u003e Construction/destruction\n*/\n//\u003c+lh#dox#tag('{')+\u003e\nVimL: let s:fn_comments = { }\nVimL: let s:fn_comments.brief = \"Default constructor.\"\nVimL: let s:fn_comments.throw = {\"optional\": 1}\nVimL: call s:Include(\"function-comment\", \"cpp/internals\",s:fn_comments)\n\u003c+s:clsname+\u003e();\n\nVimL: \"\nVimL: \" not documented, this is :DOX job\n\u003c+s:clsname+\u003e(\u003c+define the params, and document me w/ :DOX+\u003e);\n\nVimL: \"\nVimL: \" todo: support using default implementations\nMuT: if g:CppDox_do_copy\nVimL: call s:Include(\"copy-constructor\", \"cpp\", s:clsname)\nVimL: call s:Inject([\"\"])\nVimL: call s:Include(\"copy-and-swap\", \"cpp\", s:clsname)\n\nMuT: endif\nVimL: call s:Include(\"destructor\", \"cpp\",{\"name\":(s:clsname), \"virtual\": (g:CppDox_isVirtualDest) })\n//\u003c+lh#dox#tag('}')+\u003e\n\n\u003c+Other public functions+\u003e;\n\n¡IF(strlen(g:CppDox_protected_members), \"protected:\\n\", '')¡\n¡g:CppDox_protected_members¡\nprivate:\n¡g:CppDox_forbidden_members¡\n\n\u003c+Private functions+\u003e;\n\n\u003c+Attributes+\u003e;\n};\u003c++\u003e\n```\n\n### Completely useless recursive example\n  * test.template\n```\nVimL: let s:value_start  = '¡'\nVimL: let s:value_end    = '¡'\nVimL: let s:marker_open  = '\u003c+'\nVimL: let s:marker_close = '+\u003e'\nVimL: let s:var = 1\nBEGIN\u003c++\u003e\n/*\n * ¡'$'¡Id$\n */\n¡s:var¡\na¡s:var¡\n¡s:var + 5¡a\na¡s:var¡a¡s:var¡\na¡s:var¡a¡s:var¡a\nhere \u003c+we go+\u003e\nVimL: let s:msg =''\nVimL: call s:Include('test-included')\nVimL: let s:msg =' again'\nVimL: call s:Include('test-included')\n\n------\nSome tests:\nVimL: let s:expr = \"first line\\nsecond line\\n \"\ntext ¡s:expr¡\ntext\nEND\n```\n  * test-included.template\n```\nVimL: let s:times = exists('s:times') ? (s:times+1) : 1\nThis part has been included¡s:msg¡ ¡((s:times==1)?'once':(s:times==2 ? 'twice' : (s:times.' times')))¡.\nVimL: if s:times \u003c= 4 | call s:Include('test-included') | endif\nVimL: silent! unlet s:times\n```\n\n\n## Installation\n  * Requirements: Vim 7.+, [lh-vim-lib](http://github.com/LucHermitte/lh-vim-lib), [lh-style](http://github.com/LucHermitte/lh-style), and my [bracketing-system](http://github.com/LucHermitte/lh-brackets), and optionally [lh-dev](http://github.com/LucHermitte/lh-dev).\n  * With [vim-addon-manager](https://github.com/MarcWeber/vim-addon-manager), install `mu-template@lh`. This is the preferred method because of the various dependencies.\n\n    ```vim\n    ActivateAddons mu-template@lh\n    \" And don't forget\n    ActivateAddons stakeholders\n    \" don't forget also to support a few default snippets\n    ActivateAddons lh-dev\n    ```\n\n  * or you can use [vim-flavor](https://github.com/kana/vim-flavor) that also\n    supports dependencies\n\n    ```\n    flavor 'LucHermitte/mu-template'\n    \" And don't forget\n    flavor 'tomtom/stakeholders_vim'\n    \" don't forget also to support a few default snippets\n    flavor 'LucHermitte/lh-dev'\n    ```\n\n  * N.B.: installing [lh-cpp](http://github.com/LucHermitte/lh-cpp) or [lh-refactor](http://github.com/LucHermitte/lh-refactor) with VAM or vim-flavor will also install µTemplate.\n  * or you can clone the git repositories\n    ```bash\n    git clone git@github.com:LucHermitte/lh-vim-lib.git\n    git clone git@github.com:LucHermitte/lh-style.git\n    git clone git@github.com:LucHermitte/lh-brackets.git\n    git clone git@github.com:LucHermitte/mu-template.git\n    # and don't forget:\n    git clone git@github.com:tomtom/stakeholders_vim.git\n    # don't forget also to support a few default snippets\n    git clone git@github.com:LucHermitte/lh-dev.git\n    ```\n\n  * or with Vundle/NeoBundle:\n    ```vim\n    Bundle 'LucHermitte/lh-vim-lib'\n    Bundle 'LucHermitte/lh-style'\n    Bundle 'LucHermitte/lh-brackets'\n    Bundle 'LucHermitte/mu-template'\n    \" and don't forget:\n    Bundle 'tomtom/stakeholders_vim'\n    \" don't forget also to support a few default snippets\n    Bundle 'LucHermitte/lh-dev'\n    ```\n\n### Note: regarding [COC](https://github.com/neoclide/coc.nvim)\n\nSince v.4.4.0, µTemplate delegates the selection of its snippets to COC, when\nCOC is detected.\n\n## Credits\n  * Gergely Kontra is the author of the first version of µTemplate.\n  * Luc Hermitte (LH) is the current maintainer of this enhanced version of mu-template.\n  * Robert Kelly IV, Zdenek Sekera for their insight and the feedback they provided me (LH).\n  * Troy Curtis Jr, for his intensive testing.\n\n## See also\nThere are many other template-files loaders for Vim, see the [non exhaustive list of vim.wikia](http://vim.wikia.com/wiki/Category:Automated_Text_Insertion), or the [comparative matrix](http://vim-wiki.mawercer.de/wiki/topic/text-snippets-skeletons-templates.html) in Marc Weber's vim wiki.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLucHermitte%2Fmu-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FLucHermitte%2Fmu-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLucHermitte%2Fmu-template/lists"}