help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: shortcut for align-regexp


From: Doug Lewan
Subject: RE: shortcut for align-regexp
Date: Wed, 17 Apr 2013 13:20:02 +0000

The command align-regexp is written to prompt you for a regular expression if 
you use it interactively.

The following code does what you describe you want.

    (defun my-common-align (begin end)
      "Align text in the region on '=' and '<-'."
      (interactive "r")
      (let ((common-align-regexp "\\(?:=\\|<-\\)"))
        (align-regexp begin end common-align-regexp)))
    (global-set-key "\C-a" 'my-common-align)

The choice of key is yours, but `C-a' is move-beginning-of-line almost 
everywhere. I might recommend `C-c a' instead.

,Douglas
Douglas Lewan
Shubert Ticketing
(201) 489-8600 ext 224

If the majority of cooking accidents happen in the kitchen, then why don't we 
just cook in other rooms?


-----Original Message-----
From: help-gnu-emacs-bounces+dougl=shubertticketing.com@gnu.org 
[mailto:help-gnu-emacs-bounces+dougl=shubertticketing.com@gnu.org] On Behalf Of 
Jannis
Sent: Wednesday, 2013 April 17 08:35
To: help-gnu-emacs@gnu.org
Subject: shortcut for align-regexp

Hi emacs users,


this most probably is a beginners question ... googeling however yielded 
now exlanation suitable for my emacs experience.

I would love to bind single key combination (like C-a) to the 
align-regexp command and use = and <- as alignment regexpressions. How 
would I do this?

Without this I always have to type:

M-align-regexp RET <- RET


Thanks a lot
Jannis




reply via email to

[Prev in Thread] Current Thread [Next in Thread]