* Re: align-regexp for many column separators
[not found] ` <78620bdf-a2c8-4e54-84eb-74acc9c8f8c3@i21g2000yqd.googlegroups.com>
@ 2015-01-18 16:49 ` anshul.verma86
0 siblings, 0 replies; 2+ messages in thread
From: anshul.verma86 @ 2015-01-18 16:49 UTC (permalink / raw)
To: help-gnu-emacs
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)))
^ permalink raw reply [flat|nested] 2+ messages in thread
* align-regexp for many column separators
@ 2011-08-24 14:43 Michael Chen
0 siblings, 0 replies; 2+ messages in thread
From: Michael Chen @ 2011-08-24 14:43 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 251 bytes --]
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
[-- Attachment #2: Type: text/html, Size: 439 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-01-18 16:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <mailman.1919.1314247772.939.help-gnu-emacs@gnu.org>
[not found] ` <78620bdf-a2c8-4e54-84eb-74acc9c8f8c3@i21g2000yqd.googlegroups.com>
2015-01-18 16:49 ` align-regexp for many column separators anshul.verma86
2011-08-24 14:43 Michael Chen
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.