[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: align-regexp for many column separators
From: |
anshul . verma86 |
Subject: |
Re: align-regexp for many column separators |
Date: |
Sun, 18 Jan 2015 08:49:27 -0800 (PST) |
User-agent: |
G2/1.0 |
Thanks @jpkotta...works like a charm!
On Friday, September 2, 2011 at 7:59:42 AM UTC-7, jpkotta wrote:
> On Aug 24, 9:43 am, Michael Chen <vancouver.mich...@gmail.com> wrote:
> > Dear there,
> > I would like to align at "&":
> >
> > 1&2&3\\
> > 1000&2000&3000\\
> >
> > ==>
> >
> > 1 &2 &3\\
> > 1000&2000&3000\\
> >
> > M-x align-regexp only aligns the first "&", i.e., I get
> > 1 &2&3\\
> > 1000&2000&3000\\
> >
> > Any suggestions?
> >
> > --
> > All the best,
> > Michael Chen
>
> You can do it directly with align-regexp, but I can't ever remember
> exactly how when I need it. So I use this:
>
> (defun align-regexp-repeated (start stop regexp)
> "Like align-regexp, but repeated for multiple columns. See
> http://www.emacswiki.org/emacs/AlignCommands"
> (interactive "r\nsAlign regexp: ")
> (let ((spacing 1)
> (old-buffer-size (buffer-size)))
> ;; If our align regexp is just spaces, then we don't need any
> ;; extra spacing.
> (when (string-match regexp " ")
> (setq spacing 0))
> (align-regexp start stop
> ;; add space at beginning of regexp
> (concat "\\([[:space:]]*\\)" regexp)
> 1 spacing t)
> ;; modify stop because align-regexp will add/remove characters
> (align-regexp start (+ stop (- (buffer-size) old-buffer-size))
> ;; add space at end of regexp
> (concat regexp "\\([[:space:]]*\\)")
> 1 spacing t)))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: align-regexp for many column separators,
anshul . verma86 <=