HTTPS clone URL
Subversion checkout URL
Inserts named snippets from various other files into a file
Python VimL C++
Fetching latest commit...
Cannot retrieve the latest commit at this time.
|Failed to load latest commit information.|
This is a mirror of http://www.vim.org/scripts/script.php?script_id=3717 SnippetySnip is a vim tool for automatically inserting parts (snippets) of other files in a file. I wrote it to insert sourcecode examples from source files into html blog-posts, but it can be used for all sorts of text files. In the source file, you mark up a region of text (a snippet) and give it a name. In the target file, you mark where you want this particular snippet inserted. For instance: source.py: (...) #snippetysnip_begin:foo def foo(): return 0 #snippetysnip_end (...) target.html: <p><code> <!-- snippetysnip:/path/to/source.py:foo --> </code></p> When SnippetySnip is run, the function foo() from source.py is inserted into the html file, which then looks like this: target.html: <p><code> <!-- snippetysnip:/path/to/source.py:foo --> def foo(): return 0 <!-- snippetysnip_end:/path/to/source.py:foo --> </code></p> SnippetySnip does not care about the format of the comments in your particular language, it only looks for the snippetysnip-strings. You can have many snippets in a source file, and a target file can reference multiple snippets from multiple sources. Paths can be relative or absolute. ADVANCED USAGE It is possible to give arguments before="..." and/or after="..." when including a snippet. These arguments will be inserted between the snippet command and the actual snippet. Here is an example, inserting code snippets into Wordpress posts: original target: <!-- snippetysnip:source.cpp:foo:(before='[sourcecode language="cpp"]', after='[/sourcecode]') --> modified target: <!-- snippetysnip:source.cpp:foo:(before='[sourcecode language="cpp"]', after='[/sourcecode]') --> [sourcecode language="cpp"] imported(); code(); here(); [/sourcecode] <!-- snippetysnip_end:source.cpp:foo --> (This was motivated by the fact that html-comments do not work well inside [sourcecode] blocks on Wordpress)