Add `autocmd` to automatically expand the `_template` snippet on the `BufNewFile` event, if the expansion fails because the `_template` snippet does not exist for the current `filetype` undo the changes. Do the same thing when the `filetype` changes to `help`, since these are `text` files to begin with the first `autocmd` has no effect.
		
			
				
	
	
		
			25 lines
		
	
	
		
			607 B
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			25 lines
		
	
	
		
			607 B
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
snippet _template "help file template"
 | 
						|
*`!p snip.rv = snip.fn`*	For Vim version 8.0	Last change: `!p
 | 
						|
from datetime import datetime
 | 
						|
snip.rv = datetime.now().strftime('%B %d, %Y')`
 | 
						|
 | 
						|
$0
 | 
						|
 | 
						|
 vim:tw=78:ts=8:ft=help:norl:
 | 
						|
endsnippet
 | 
						|
 | 
						|
snippet s "help section"
 | 
						|
==============================================================================
 | 
						|
${1:1}. ${2:Section}`!p
 | 
						|
spaces = 78 - len(t[1]) - len(snip.basename) - (2 * len(t[2])) - 3
 | 
						|
snip.rv = spaces * ' ' + '*' + snip.basename + '-' + t[2].lower() + '*'`
 | 
						|
 | 
						|
$0
 | 
						|
endsnippet
 | 
						|
 | 
						|
snippet d "help detail"
 | 
						|
`!p spaces = 78 - len(t[1])
 | 
						|
snip.rv = spaces * ' '`*${1:}*
 | 
						|
$0
 | 
						|
endsnippet
 |