vim-template
vim-template copied to clipboard
template comments
Is there some way that a template file could have comments, that were there for development or explanation of the template, but that was never translated to the generated file.
either a vim-style comment (which might not work great for vim-files where the commented part is desirable)
" a vim-style in-line comment
or something hopefully unique to vim-template, like
%%% this is a vim-template comment
or maybe a block-comment style, like this;
%COMMENT_START% These are template comments, and won't be included in the transformation %COMMENT_END%
for consistency, perhaps, if a line starts with;
%COMMENT% <-- a vim-template comment, this line will be ignored
and for block-comments;
%COMMENT_START% anything on this line will be ignored These are template comments, and these four lines won't be included in the transformation %COMMENT_END% this line is ignored, too
Hmm. What is the use case of this? Do you have templates that are so complex that they need documentation? I would hope that the template files are readable as is.
Here's one: a template specific modeline. I'm editing templated for vimwiki, they have vimwiki formatting the with the *.wiki extension, the behaviors and mapping are not helpful, in editing the related templates, so
# vim: foldlevel=3 %COMMENT_START% # vim: filetype=txt %COMMENT_END%
(caveat: I don't know how to use modelines very well ;-) The bottom modeline would (should) apply when editing the template, but would not apply to the transformed file.
Another use-case might be this:
%COMMENT_START$------------------------------- | This is a vim-template template | | http://github.com/aperezdc/vim-template | | ---- | | Licensed under the BlaBlaBlaPublic License | | http://licenses.com/BBBP/ | | --- | | Author: Edgar Allen Poe | | --- | | This template designed for: vimwiki diary | | | | and requires: | | | %COMMENT_END%---------------------------------
Probably matching comment start/end pairs would end up in some complex code. Personally I would prefer to only support single-line comments. I am not so sure about what would be the best character for commenting. From the less usual line-comment characters, probably %
is the less used — I can only think about TeX. We could match a double (or triple?) percent character exactly at line start, to reduce the chance of clashing with other kinds of comments or valid syntax in some language:
%%% This would be a template comment.
% This would NOT be a comment. It could be a TeX comment, though.
%%% This is NOT a comment either
This would also have the nice property that matches lines can be completely deleted, and there is no need to preserve the content present before %%%
— because there's never content if the match is at the start of the lines.