Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files


  • Loading branch information...
commit 9422ba93b4141dbd795eadf02b7a589b7316d8b8 1 parent 2ed2094
@yanick yanick authored
Showing with 49 additions and 0 deletions.
  1. +49 −0 danceradvent/public/articles/2012/ultisnips
49 danceradvent/public/articles/2012/ultisnips
@@ -0,0 +1,49 @@
+=head1 The Gift Of Auto-Completion
+A good programmer, just like a good North Pole elf, needs good tools to
+perform his craft. One of the classics is code snippet auto-completion.
+The I<vim> editor has a few of them. Two of the best-known ones are
+I<snipMate>, L<>, inspired by the
+much liked I<TextMate> editor (L<>), and the
+newly-emerging I<UltiSnips> (L<>).
+Up to recently, I only knew (and loved quite dearly) I<snipMate>, but after
+discovering I<UltiSnips>, I must say that I'm quite impressed by it. ... ah
+well, there is no point to make you kids wait to unwrap your present: you can
+go and get it at L<>. Yes, it's a snippet file
+for the whole of Dancer's DSL. Not as exciting as a Rocket-Raptor Sky
+Armageddon action figure, granted, but much better than a rainbow-colored pullover.
+=head2 Let's Have Some Milk With Those Cookies
+With I<UltiSnips> and the snippet file given above, the whole Dancer DSL
+is at your fingertip by just issuing the vi command
+ :UltiSnipsAddFiletypes dancer
+Which is awesome. But this is Dancer; awesome is our bread and butter. Can we
+somewhat make this ultrawesome? Well, how about have I<UltiSnips> discover all
+by itself if a file is Dancer-related, and active its snippets automatically
+by adding to our I<.vimrc>:
+ au BufNewFile,BufRead *.pl,*.pm call s:detectTypeOfPerl()
+ fun! s:detectTypeOfPerl()
+ perl <<EOF
+ for ( 0..$curbuf->Count ) {
+ if ( $curbuf->Get($_) =~ /use Dancer/ ) {
+ VIM::DoCommand(':UltiSnipsAddFiletypes dancer');
+ return;
+ }
+ }
+ endfun
+Aaaah yes. Just like a little swig of rum in a mug of eggnog, this is making
+what was already a treat into something truly decadent... Enjoy!
+=head2 Author
+This article has been written by Yanick Champoux for the Perl
+Dancer Advent Calendar 2012.

0 comments on commit 9422ba9

Please sign in to comment.
Something went wrong with that request. Please try again.