Skip to content

Instantly share code, notes, and snippets.

@dfm
Created April 26, 2011 03:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dfm/941740 to your computer and use it in GitHub Desktop.
Save dfm/941740 to your computer and use it in GitHub Desktop.
Python template
" TEMPLATES
function! LoadTemplate()
" load a template based on the file extension
silent! 0r ~/.vim/skel/tmpl.%:e
" Replace some placeholders
%s/%FILENAME%/\=expand("%:t")/g
%s/%DATE%/\=strftime("%b %d, %Y")/g
" This last one deletes the placeholder
" %START% then leaves the cursor there.
%s/%START%//g
endfunction
autocmd! BufNewFile * call LoadTemplate()
#!/usr/bin/env python
# encoding: utf-8
"""
%FILENAME%
Created by <Your Name> on %DATE%
"""
import numpy as np
import pylab as pl
def main():
%START%
if __name__ == '__main__':
main()
@dfm
Copy link
Author

dfm commented Aug 12, 2012

@dfm test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment