Last Updated: February 25, 2016
·
816
· 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.

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.

Security insights from Cside