For example, jsbeautifier.org, essentially something to make your code look better.
This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
Lua Beautifier/Formatter/Indenter?
Started by oeed, 06 March 2013 - 05:56 PMPosted 06 March 2013 - 06:56 PM
Is there any (preferably online or Java) good tool I can use to fix up the formatting of a Lua file. The code is around 2150 lines so I want to avoid having to do it by myself. I tried Googling but I couldn't find anything which appears to do the job.
For example, jsbeautifier.org, essentially something to make your code look better.
For example, jsbeautifier.org, essentially something to make your code look better.
Posted 06 March 2013 - 08:27 PM
Download Sublime Text 2.
It has a re-indent feature for Lua, but it's a bit broken (doesn't indent at elseifs). If you download my ComptuerCraft Sublime Text 2 package, and set the language to ComputerCraft (should appear once you've installed it), then run the reindent feature (select the whole document, remove any current tabbing using shift+tab, then do edit->line->re-indent).
It has a re-indent feature for Lua, but it's a bit broken (doesn't indent at elseifs). If you download my ComptuerCraft Sublime Text 2 package, and set the language to ComputerCraft (should appear once you've installed it), then run the reindent feature (select the whole document, remove any current tabbing using shift+tab, then do edit->line->re-indent).
Posted 06 March 2013 - 08:32 PM
There is a CC program to do that here, but that might not be what you're looking for.
Posted 06 March 2013 - 08:41 PM
Download Sublime Text 2.
It has a re-indent feature for Lua, but it's a bit broken (doesn't indent at elseifs). If you download my ComptuerCraft Sublime Text 2 package, and set the language to ComputerCraft (should appear once you've installed it), then run the reindent feature (select the whole document, remove any current tabbing using shift+tab, then do edit->line->re-indent).
Thanks! Even better than I was asking for. I've been using BBEdit but this is even better.
Posted 06 March 2013 - 11:42 PM
Download Sublime Text 2.
It has a re-indent feature for Lua, but it's a bit broken (doesn't indent at elseifs). If you download my ComptuerCraft Sublime Text 2 package, and set the language to ComputerCraft (should appear once you've installed it), then run the reindent feature (select the whole document, remove any current tabbing using shift+tab, then do edit->line->re-indent).
Thanks! Even better than I was asking for. I've been using BBEdit but this is even better.
Glad to help :P/>
I use it for absolutely everything except for Objective-C (Xcode) and Java (Eclipse).
Posted 07 March 2013 - 02:28 AM
the ultimate solution!
Spoiler
Indent it correctly right from the start, makes life so much better and easier, and makes debugging a DREAM!Posted 07 March 2013 - 02:41 AM
the ultimate solution!Spoiler
Indent it correctly right from the start, makes life so much better and easier, and makes debugging a DREAM!
Debugging is never a dream unless it's a syntax error (cause they're easy to fix :P/>)
Posted 07 March 2013 - 03:00 AM
I never have a problem with debugging. there are a few annoying times. but for the most part. its not hard.Debugging is never a dream unless it's a syntax error (cause they're easy to fix :P/>)
Posted 07 March 2013 - 03:18 AM
I never have a problem with debugging. there are a few annoying times. but for the most part. its not hard.
I agree, it's not always too hard, but some times is some randomly obscure thing that is impossible to find without logging everything you do. And for those times, I have 1lann to do it for me :P/>
Posted 07 March 2013 - 03:26 AM
You should try C++ … compiler errors are useless and errors are hard to track down …but some times is some randomly obscure thing that is impossible to find
Posted 07 March 2013 - 04:50 AM
You should try C++ … compiler errors are useless and errors are hard to track down …but some times is some randomly obscure thing that is impossible to find
Are you kidding me? They give you all the information you need.
Posted 07 March 2013 - 08:13 AM
I must say that debugging lua became simple as soon as I tried out brainf**ck for the first time.
On topic though, indenting correctly from the start is really not that difficult unless you write the program in something that does not support indentation (I have a lua app on my tablet that doesn't). Sublime Text is the ultimate solution for this that I've found (Thanks GravityScore!)
On topic though, indenting correctly from the start is really not that difficult unless you write the program in something that does not support indentation (I have a lua app on my tablet that doesn't). Sublime Text is the ultimate solution for this that I've found (Thanks GravityScore!)
Posted 07 March 2013 - 01:54 PM
the ultimate solution!Spoiler
Indent it correctly right from the start, makes life so much better and easier, and makes debugging a DREAM!
I agree, however, it can be a pain if you're adding and removing stuff lots.
Download Sublime Text 2.
It has a re-indent feature for Lua, but it's a bit broken (doesn't indent at elseifs). If you download my ComptuerCraft Sublime Text 2 package, and set the language to ComputerCraft (should appear once you've installed it), then run the reindent feature (select the whole document, remove any current tabbing using shift+tab, then do edit->line->re-indent).
The reindenting doesn't appear to work with tables, which is a shame.
Posted 07 March 2013 - 06:17 PM
Someone made a patch for tables. I can't find it on google, so I just pastebinned my own.
http://pastebin.com/UVLRMDjn
Text goes in the file:
Windows: %APPDATA%/Sublime Text 2/Packages/Lua/Indent.tmPreferences
Linux: ~/.sublime-text-2/Packages/Lua/Indent.tmPreferences
I forget what it is for Mac.
http://pastebin.com/UVLRMDjn
Text goes in the file:
Windows: %APPDATA%/Sublime Text 2/Packages/Lua/Indent.tmPreferences
Linux: ~/.sublime-text-2/Packages/Lua/Indent.tmPreferences
I forget what it is for Mac.
Posted 07 March 2013 - 06:42 PM
Someone made a patch for tables. I can't find it on google, so I just pastebinned my own.
http://pastebin.com/UVLRMDjn
Text goes in the file:
Windows: %APPDATA%/Sublime Text 2/Packages/Lua/Indent.tmPreferences
Linux: ~/.sublime-text-2/Packages/Lua/Indent.tmPreferences
I forget what it is for Mac.
Thanks, it makes a lot better, still a few glitches but overall much better.
(Woot, 100th post)
Posted 07 March 2013 - 08:26 PM
Text goes in the file:
Windows: %APPDATA%/Sublime Text 2/Packages/Lua/Indent.tmPreferences
Linux: ~/.sublime-text-2/Packages/Lua/Indent.tmPreferences
I forget what it is for Mac.
Mac: ~/Library/Application Support/Sublime Text 2/Packages/Lua/Indent.tmPreferences
Posted 17 August 2013 - 07:24 AM
Anyone else found that this doesn't decrease the indent for "until" in repeat loops?
Posted 17 August 2013 - 07:37 AM
yeh it's a common problem with most indenters.Anyone else found that this doesn't decrease the indent for "until" in repeat loops?