Skip to content

September 9, 2011

Emacs command line to indent Javascript code and convert tabs to spaces

by Joe Kuan

Part of my project checkin script is to automatically apply coding style and converting tabs to spaces. Here is the command line:

emacs -batch file.js --eval "(custom-set-variables '(js-indent-level 2))"  -f mark-whole-buffer -f indent-region -f mark-whole-buffer -f untabify -f save-buffer -kill

Change the value of js-indent-level to any religion of white spaces.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Note: HTML is allowed. Your email address will never be published.

Subscribe to comments

%d bloggers like this: