Questions tagged [align]

Use the align tag for questions about aligning text vertically. For example, formatting tables so the columns in a row line up under the columns in the previous row; or having consecutive rows of text arranged to keep a symbol/separator in the same column, such as the equal sign in equations, or a series of variable assignments.

The Emacs functions align, align-current, align-entire and align-regexp support different ways of achieving text alignment.

75 questions
15
votes
2 answers

Is there an auto-align package or mode for Emacs?

There are times when I'm editing files (Puppet manifests, for example) where I want to align buffer contents on the fly. For example, I know that I can use align-regexp or align to align code like this, as long as I have it selected: # M-x…
9
votes
1 answer

Emacs align matrices

Since I find myself writing a lot of matrices and tables, I'm looking for a way to align numbers nicely in Emacs (similar to the align package in vim). I found that there is align-regexp, but I couldn't get it to work the way I wanted. Is there a…
DayAndNight
  • 203
  • 1
  • 5
6
votes
1 answer

How align tabs inside block of string?

For example, I have the following code snippet: $query = 'SELECT SUM(T01.foobar) FROM db_foo.bar T01 WHERE T01.fooID = 1 AND T01.barID = 2 AND T01.foo IS NOT NULL' I would like to align it…
ReneFroger
  • 3,850
  • 23
  • 66
5
votes
1 answer

How to right-align with align-regex?

Initial buffer &ei = wFSXYvnUEvaL6dsP9f2HsAE &ip = 195.201.109.29 &id = o-AD7SgDnv171kT3qy-KSuSbDZ3zX4YR5X7cS6Mmq237oY &itag = 22 &source = youtube &requiressl = yes &vprv = 1 &mime = video%2Fmp4 &cnr = 14 &ratebypass = yes &dur = 193.863 &lmt =…
ychaouche
  • 207
  • 1
  • 7
4
votes
1 answer

How to make Emacs align-regexp work with leading spaces

If I try and use emacs C-u align-regexp on the below with \(\s-*\)| and 1 and 1 and y I get an incorrectly formatted result: Foobar Foobar foobar| foobar foobar | || Incorrectly formatted result: Foobar Foobar foobar |…
Mike H-R
  • 265
  • 1
  • 8
3
votes
1 answer

How to contribute align rules

I've been working on align-rules for Fortran 90 so that the built-in align and align-current functions do something useful. What would be the best way to make this code available for others?
2
votes
2 answers

How can I create an Emacs keyboard macro to make Clojure code easier for humans to read it?

I am working on a Clojure codebase. Sometimes, we have code as: :boxes [{:id "Do-not-map" :description "Do Not Map, expenses" :line "0" :cch-box-number "0" :import-tax-code "0" :reporting {:omit-taxable true}…
Pedro Delfino
  • 1,489
  • 3
  • 16
2
votes
0 answers

Can align-current handle aligning a varying number of columns?

I'm attempting to write a rule for align-current for Robot Framework tests. Columns are delimited by multiple spaces in a row (I know, what an awful choice) and each row can have a varying number of columns (essentially each column is a function…
dshepherd
  • 1,281
  • 6
  • 18
1
vote
0 answers

Passing function to align-region raises an error when using 'justify' rule

I have *test* buffer with following contents: 1234 23347 35466 155555 267 31 1444444 2444 32777 Now I'm trying to understand how passing a callback to align-region works, so I wrote this script: (let* ((group -1) …
mkcms
  • 1,370
  • 12
  • 13
1
vote
1 answer

How do I align a block of text into columns?

For instance, let's say I have the following block of code in a buffer: pattern TTF_STYLE_NORMAL = #{const TTF_STYLE_NORMAL} pattern TTF_STYLE_BOLD = #{const TTF_STYLE_BOLD} pattern TTF_STYLE_ITALIC = #{const TTF_STYLE_ITALIC} pattern…
liszt
  • 735
  • 1
  • 5
  • 11
0
votes
1 answer

How to use align-regex to align text as column or matrix?

I am trying to align code using align-regex but I could not figure out how to solve the below problem. This is what I have: public class Person { public static String id = ""; private String name = ""; public int age = 10; } This is…
tammary
  • 3
  • 3
0
votes
0 answers

Simple align-regexp example

I'm trying to align 4000 1 2 4000 1 2 11 1 44 => 11 1 44 1 0000 999 1 0000 999 as described at http://emacswiki.org/emacs/AlignCommands However, typing in C-u M-x…
Trent Gm
  • 101
  • 3