Enable editplus to automatically format CSS and JS

Source: Internet
Author: User

Inspired by a's colleagues, I also made a little thing.

Although editplus is very small and fast, it is a pity that it does not supportCodeAnd now PHP, CSS, and HTML are all using Aptana.

Today, I took a look at editplus.
User tool, which can be called through the command line and the standard output and otherProgramInteraction. You can specify parameters manually, or select the selected content, all the current text, and so on.
You can use the filter mode to transfer all text content, and then use the return content to replace the current text. We also need an external tool. For convenience, the script language is of course the first
Choose, and in the Windows platform can use vbs and JScript, then use JScript, go to the Internet to find a http://github.com/einars/js-beautify/tree/master, it provides online JS Formatting Function, it's exactly written in JS. Take it back and make some modifications. Use the STD interface of wscript to receive and send content.
VaR input = "";
While (! Wscript. stdin. atendofstream)
{
Input + = wscript. stdin. readall ();
}
Reads data from the input.
Wscript. Echo (formated_code); send data.
Then the JS formatting is done,
Let's take a look at CSS. We miss it very much. In this case, we can put a CSS definition on one line, which looks more convenient. Otherwise, the code will take a long time. this does not seem too difficult,
Write one by yourself. I have packed the two files. After downloading the files, decompress them to any directory and configure editplus.

Open tools> configusertools. The tool name can be customized, such as jsformatter.
The path after cscript.exe/nologo E: \ jsformatter. JS is the reference path of JS, and the following run as text
Fileter, let it be used as a text filter, OK, now open a JS file to be formatted, press Ctrl + 1 (the default first user tool shortcut ),
You can see that the text has been formatted,But wait. How is the copyright statement issued by Ms above? It seems that this cscript is not a white drop ;(
But it doesn't matter. We still have a solution. Press Ctrl + Q, save it to Alt + 1, start recording, and press
CTRL + home go back to the beginning of the document,
Alt + Shift + DEL three times, delete three rows
Press Ctrl + Q to exit the record. After formatting, play the keyboard operation record once.Thank you for your reminder..


Postscript:
It would be better to format HTML and PHP. js-beautify
HTML can also be formatted in it. Unfortunately, the effect is not very good. I didn't put it in it. It would be nice to have the excellent effect of the Aptana editor. It can perfectly process JS scripts, CSS,
The mixed HTML formatting seems like you can create a Java console program to reference the plug-in jar package of Aptana,
Icodeformatter can be used to format various types of code.

The orangutan who does not make tools will always be an orangutan, and programmers who make their own tools can effectively improve their productivity. VBScript in windows,
JScript, Python, Perl, and other scripting languages are good assistants.
In this application, first check the editplus help and then search for the msdn script technical reference. By the way, review the regular expression application to solve the problem and improve the skill level.
Do it yourself, good luck!

For the two files, see the attachment darkangle_js_css_formatter.rar.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.