Emacs cperl-mode: how to line up middles of rows?
Roscoe
created: 2006-02-02 18:44:46
The Praise section of cperl's Micro-docs brags that cperl:
        b) Can lineup vertically "middles" of rows, like '=' in
                a  = b;
                cc = d;
Great! Now how is this done? I tried using cperl-lineup on a marked region, but that wasn't it.
Re: Emacs cperl-mode: how to line up middles of rows?
created: 2006-02-02 18:55:49
Dunno, but I use perltidy to do stuff like this. I call it from emacs using:

(defun perltidy-region ()
    "Run perltidy on the current region."
    (interactive)
    (save-excursion
      (shell-command-on-region (point) (mark) "perltidy -q" nil t)))
(global-set-key "\M-t" `perltidy-region)

Then I just mark a region and hit alt-t to pretty it up. I also have a binding to allow me to perltidy the whole file.

-sam

Re: Emacs cperl-mode: how to line up middles of rows?
created: 2006-02-02 21:46:21

cperl-linup is the correct function, but you have to use it carefully. The mark must be at the character that you wish to line up (hit C-space while on the first "="). Then go to the end of the region and execute cperl-lineup (C-M-| by default I believe).

Good Day,
    Dean

Re^2: Emacs cperl-mode: how to line up middles of rows?
created: 2006-02-03 15:03:07
Thanks duelafn, this is exactly what I was looking for. It works!
Re: Emacs cperl-mode: how to line up middles of rows?
created: 2006-02-02 23:05:03
I have used the align-regex function in several buffer modes.

Select your region. M-x align-regex . Press the '=' key. Press the 'Enter' key.
Re^2: Emacs cperl-mode: how to line up middles of rows?
created: 2006-02-03 11:20:55

It's probably a useful idea to set align-indent-before-aligning t (true) before using align-regexp, otherwise it may muck up the code indentation.

emc

" When in doubt, use brute force." — Ken Thompson

perlmonks.org content © perlmonks.org and duelafn, Roscoe, samtregar, superfrink, swampyankee

prlmnks.org © 2006 edmund von der burg (eccles & toad)

v 0.03