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.