From: Jesse Luehrs Date: Tue, 12 May 2009 03:44:47 +0000 (-0500) Subject: better remove empty line function X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c7adedbcb10f6d0eef859e19dfe13613272c45f7;p=gitmo%2Fmoose-dev-utils.git better remove empty line function --- diff --git a/vim/moose_snippets.vim b/vim/moose_snippets.vim index ae377a6..bfe9f90 100644 --- a/vim/moose_snippets.vim +++ b/vim/moose_snippets.vim @@ -5,18 +5,13 @@ if !exists('loaded_snippet') || &cp finish endif -function! RemoveEmptySuperClass() - if @z == "SuperClass" - s/extends '<{}>';\n\n//e - return "" +function! RemoveUnchangedLine() + if match(getline('.'), "<{}>") >= 0 + normal! dd + return '' + else + return @z endif - - return @z -endfun - -function! RemoveEmptyLine() - s/^\s*<{}>\s*\n//e - return @z endfun function! Snippet(abbr, str) @@ -55,7 +50,7 @@ call Snippet('class', [ \"package ".ParameterizedModule().";", \"use Moose;", \"", - \"extends '<{SuperClass:RemoveEmptySuperClass()}>';", + \"extends '<{SuperClass:RemoveUnchangedLine()}>;", \"", \"<{}>", \"", @@ -76,14 +71,14 @@ call Snippet('has', [ \"has <{attr}> => (", \ "is => '<{rw}>',", \ "isa => '<{Str}>',", - \ "<{options:RemoveEmptyLine()}>", + \ "<{options:RemoveUnchangedLine()}>", \");"]) call Snippet('hasl', [ \"has <{attr}> => (", \ "is => '<{rw}>',", \ "isa => '<{Str}>',", \ "lazy_build => 1,", - \ "<{options:RemoveEmptyLine()}>", + \ "<{options:RemoveUnchangedLine()}>", \");", \"", \"sub _build_<{attr}> {", @@ -93,6 +88,7 @@ call Snippet('hasl', [ call Snippet('sub', [ \"sub <{name}> {", \ "my $self = shift;", + \ "my (<{arg:RemoveUnchangedLine()}>) = @_;", \ "<{}>", \"}"]) call Snippet('around', [