Emacs: align perl hash with align-current
I often write Perl script and use hash heavily. But I feel boring (and a little bit stupid) to align “=>” manually. For example, press SPACE to align
my %h =
(
key1 => value1,
key11 => value11,
key111 => value111,
);
to
my %h =
(
key1 => value1,
key11 => value11,
key111 => value111,
);
After reading Ruslan’s align-regexp, I find align-current and bind it to C-c C-c in cperl-mode.
(define-key cperl-mode-map "\C-c\C-c" 'align-current)
So, I can align those lines of Perl code simply by moving cursor to one of three lines and pressing C-c C-c.
1 Comment »
Leave a comment
About
I’m a compiler developer on Shanghai, China. I write C++ and Perl program with Emacs. When I learn programming, I’m addicted to open source software. So I’m going to post something about open source software here. Hope my share can help you.
The main thing i’m enjoying while reading your blog is the way you write, you are a really charismatic person and your posts are wonderful, keep it up!