aligning or prettifying code in emacs

719016 picture 719016 · Jun 2, 2011 · Viewed 7.5k times · Source

I remember this was possible in emacs, but don't know how. If I have something like:

'abc' => 1,  
'abcabc' =>2,  
'abcabcabc' => 3,  

How can I align the keys, arrows and values to something like this?

'abc'       => 1,  
'abcabc'    => 2,  
'abcabcabc' => 3,  

Cheers

Answer

ShreevatsaR picture ShreevatsaR · Jun 2, 2011
  • Select the region.

  • Type M-x align-regexp RET

  • Type = and hit enter.