" This file contains some simple functions that attempt to emulate some of the " behaviour of 'Snippets' from the OS X editor TextMate, in particular the " variable bouncing and replacement behaviour. " " This is the first release and so is a bit rough around the edges. " " USAGE: " " 'source' the file and define your 'snippets' using the Iabbr command. " The syntax of the command is the same as for 'iabbr'. " Variables are tagged with @'s. " " Example: " " Iabbr forin for @element@ in @collection@ @element@.@@ end " " The above will expand to the following (indenting may differ): " " for @element@ in @collection@ " @element@.@@ " end " " The cursor will be placed after the first @ in insert mode. " Pressing will 'tab' to the next place marker (@collection@) in " insert mode. Adding text between the @@s and then hitting will " remove the @s and replace all markers with a similar identifier. " " Eg: " With the cursor at the pipe, hitting will replace: " for @MyVariableName|element@ in @collection@ " @element@.@@ " end " " with (the pipe shows the cursor placement): " " for MyVariableName in @|collection@ " MyVariableName.@@ " end " " Enjoy. " " Known Bugs: " Empty tag replacement. Changing an empty tag will change all remaining " empty tags " " Short variable names. Having a single character in the tags will mess up " the insert point. if exists('loaded_snippet') || &cp finish endif let loaded_snippet=1 if !exists("g:snip_start_tag") let g:snip_start_tag = "<" endif if !exists("g:snip_end_tag") let g:snip_end_tag = ">" endif if !exists("g:snip_elem_delim") let g:snip_elem_delim = ":" endif if ( !hasmapto( 'Jumper', 'i' ) ) imap Jumper endif imap