quickly beautify your javascript in emacs

This is for the javascript version of js-beautify and could easily apply to their python version as well. You’ll need to have node installed with npm and run the following:

Next, open up your emacs init file (~/.emacs.d/init.el) and add the following lisp code:

Once you’ve re-evaluated or restarted emacs the (CTRL+c then g) will be bound to the jstidy function.

Finally, load up any javascript file and either mark a region or not and press the key commands to execute jstidy and you should see your code re-formatted nicely.

CC BY-SA 4.0
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

+ 2 = eight

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">