I am using emacs cperl-mode. When I type
if(
it gives me the code template:
if(<cursor goes here>){
}
But I want to make it like this:
if(<cursor goes here>){
<tab, according to the mode>
}
So after I wrote the condition inside 'if', I won't need to click <End> <Enter> <tab> and will only need to click <Down arrow>.
The same method can be used for the similar cases: while, for, etc.
I use Yasnippet to cover this case:
YASnippet is a template system for Emacs. It allows you to type an abbreviation and automatically expand it into function templates. Bundled language templates includes: C, C++, C#, Perl, Python, Ruby, SQL, LaTeX, HTML, CSS and more. The snippet syntax is inspired from TextMate's syntax, you can even import most TextMate templates to YASnippet.
Your case would be just i f tab condition tab then block.
In cperl-mode you have following default templates:
eval, for, fore, if, ife, ifee, sub, unless, while, xfore, xif, xunless, xwhile
and - what's even more awesome - you can easily create your own templates or use an existing collection of yasnippet snippets for many languages.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With