Emacs: how to get rid of the unwanted tab in perl-mode yasnippet

173 Views Asked by At

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?

1

There are 1 best solutions below

3
On BEST ANSWER

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
}
# }}}