A while back @psquid gave me a new perspective on things.
I can’t remember what the discussion was about, but it left me with the realization that my current system (of having file type templates in vim coming with predefined licenses (GPL v3)) was flawed.
The thing I believe he got out of the discussion was that one could use snipMate to define ones own shortcuts for inserting licences into source code.
I couldn’t tell you why I hesitated so long before trying it, since the idea seemed sound. But when I did try it I came to two conclusions:
(1) It wouldn’t work the way I wanted it to , or (2) at least not without duplication.
Since I on occasion program both Python, Java, PHP, Bash and, infrequently, Erlang, in order to have licensing snippets (think GPL3, BSD, and the odd CC By-SA) I’d need to put these license-blurbs into each snippet file that should support it (since Python don’t do C-style comments, and Erlang-style comments are completely different as well)
So what I wanted was some way to call a Vim command (say NERD Commenter ( ,,cs )) once a certain snippet (the license blurb) had been expanded.
I am pretty sure this can’t be done in an easy way, so I gave that idea up. Mapping a key, say F3, to a user defined command in my .vimrc, however, would be much easier.
Something along the lines of:
function! GPL3() r~/static/templates/gpl3 :.,$call NERDComment(0, 'sexy') endfunction nmap :call GPL3()
I am not well-versed at all with scripting vim, so I have probably made some embarrassing mistakes (for one, I should probably read up on what the heck that exclamation mark at the beginning of the function does. Please do point out any mistakes.)
All in all I am pretty content with this solution, but if someone know of a way to trigger a command after a snipMate expansion (and only on specific expansions, and only on the specific expanded lines) I am all ears.
(This since there is a _.snippet which seem to be included in all instances regardless of file type, which means I could still have the licenses in one place, defined once, but used with different comments anyway, which would be awesome)