是否可以在记事本 + + 中缩进 JavaScript 代码?

我有一些 JavaScript 代码写在一行(没有回车) ,它是完全不可读的..。

使用 Notepad + + ,我尝试将这些字符({};)替换为它们自己加上一个回车符,但它仍然不是很方便..。

有没有一种方法可以在记事本 + + 中正确地做到这一点?

130439 次浏览

I think you want a code beautifier, this one looks quick and easy: http://jsbeautifier.org/

Use jsbeautifier instead of trying to do it manually.

Could you use online services like this ?

Update: (as per request)

Google chrome will do this also http://cristian-radulescu.ro/article/pretty-print-javascript-with-google-chrome.html

Try the notepad++ plugin JSMinNpp(Changed name to JSTool since 1.15)

http://www.sunjw.us/jsminnpp/

JSTool is the best for stability.

Steps:

  1. Select menu Plugins>Plugin Manager>Show Plugin Manager
  2. Check to JSTool checkbox > Install > Restart Notepad++
  3. Open js file > Plugins > JSTool > JSFormat
    screenshot

Reference: