Here are steps (I hope u are using latest version Ubuntu Linux, and having python).
Step1:Install gedit plugin "External Tools".
open gedit and go to edit->preferences->plugins(tab)
see if you already have a plugin "External Tools", if not install using this command.
After inslalling enable this plugin from edit->preferences->plugins(tab).$ sudo apt-get install gedit-plugins
Step2: Install Rhino Shell.
To check whether you already have "Rhino Shell" or not, type "js" on Command Line.
You can Install "Rhino Shell" by typing this command.
Step3: Download einars-js-beautify.$ sudo apt-get install rhino
You can download it here http://github.com/einars/js-beautify .
Extract it in some folder. lets say you have extracted it in folder
Step4: Configure plugin to use jsbeautify.
Now go to "gedit->tools->manage external tools" and add a new command script, with following description.
#!/usr/bin/env python import os import sys import tempfile jsbeautify_path = "/home/markandey/dev/einars-js-beautify/" content = sys.stdin.read() h, tmpfile = tempfile.mkstemp() os.close(h) f = open(tmpfile, "w") f.write(content) f.close() cmd = "js beautify-cl.js -i 4 %s"%(tmpfile) os.chdir(jsbeautify_path) content = os.system(cmd) os.remove(tmpfile)
use these attributes.
Input: Current Selection.
Output: Replace the current selection.
Applicability: All documents.
That's it! you are done!
Thanks for reading my blog.
very cool & good js típs, thank you very much for sharing.ReplyDelete
This saved me a bunch of time. I also learned a lot about gedit. Thanks very much.ReplyDelete