Last Updated: February 25, 2016
·
637
· paparent

Emacs: Aling variables in Javacript

This is my first code snippet, comments are welcome!

I use this to align my variables (especially require()) in Javascript/Nodejs.

(defun pap/alignvar ()
  (interactive)
  (save-excursion
    (mark-paragraph)
    (align-regexp (region-beginning) (region-end) "\\(\\s-*\\)=")))

(global-set-key (kbd "M-+") 'pap/alignvar)

You just have to be on any line of your variable declaration, and it will align all the = sign vertically.