0

I have the following yasnippet in perl-mode to create a sub:

#name : sub ... { ... }
#key: sub
# --
sub ${1:function_name}
# {{{
{
    $0
}
# }}}

But when Emacs expands it, it generates an unwanted tab:

sub function_name
    # {{{ <-- ?
{

}
# }}}

I don't don't have this tab in the snippet definition, so it seems, that it is added by cperl-mode (perl-mode yasnippets are activated in cperl-mode). How to get rid of it?

user4035
  • 22,508
  • 11
  • 59
  • 94

1 Answers1

2

When you insert a snippet, indentation is performed automatically. Add a line to your snippet to prevent this behavior as follows:

#name : sub ... { ... }
#key: sub
#expand-env: ((yas-indent-line 'fixed))
# --
sub ${1:function_name}
# {{{
{
    $0
}
# }}}
Nicolas Dudebout
  • 9,172
  • 2
  • 34
  • 43
  • What version of yasnippet are you using? Did you reload everithing? Where is your snippet located? – Nicolas Dudebout Jun 07 '13 at 11:25
  • Ahh, sorry, I compiled the snippets, and the cached version was used. Now it works. How can I force-recompile the yasnippets, every time I change any of them? Or is it a subject for a separate question? – user4035 Jun 07 '13 at 11:31
  • 1
    I just use `yas-reload-all` when I am working on my snippets. – Nicolas Dudebout Jun 07 '13 at 11:32