Skip to content

Commit

Permalink
Add vim plugin that starts new specs from a template
Browse files Browse the repository at this point in the history
  • Loading branch information
sol committed Mar 30, 2012
1 parent db9989e commit cc75bb0
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions vim/plugin/create-hspec.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
" vim: set ts=4 sw=4 et:

" Start new specs from a template.
au BufNewFile *Spec.hs call s:CreateSpecTemplate()

let s:template = expand("<sfile>:h") . "/../../example/Spec.hs"

function s:CreateSpecTemplate()

" read template
let input = readfile(s:template)
call append(0, input)

" append leaves an empty line at the end of the file, remove it
d

" adapt module name
0
execute 's/\<Spec\>/' . expand("%:t:r")

" place cursor on first describe
/describe
endfunction

0 comments on commit cc75bb0

Please sign in to comment.