Script Editor - Code Formatting Improvements and New Features

Hi, developers!

We’ve been hard at work on the new Script Editor and today we’re very excited to introduce new features that will make development in Studio more intuitive and easy to use.

Easy Code Formatting

Now you can format your code instantly based on your indentation rule! Select any block of code (or the entire document) and then use one of the following options to format your code:

  1. Hotkey: Option+Shift+F for Mac and Alt+Shift+F for Windows
    This hotkey is also customizable from File > Advanced > Customize Shortcut

  2. Right click context menu

image

  1. Ribbon bar under the Script Menu

Pasting code into Studio just got a lot easier!

Any code you copy outside of Studio and paste into the script editor will automatically be formatted according to your preferences!

This is the old behavior:

New behavior:

If you would like to turn this off, go to File > Settings > Studio > Format on Paste

The War Between Tabs vs Spaces

Up until now you could only indent using Tabs in Studio. BUT for people that are interested, you can now use spaces to indent and customize the space width accordingly. Roblox recommends using tabs for indentation and that will be the default.

To turn this feature on, go to Settings > Studio > Indent Using Spaces

New Hotkeys for Indenting & Unindenting Your Code

Tab and shift/tab have been the only way to indent and unindent your code so far. Now you can use Cmd+] to indent and Cmd+[ to unindent (or Ctrl+] to indent and Ctrl+[ to unindent in Windows). These shortcuts are also customizable in the File > Advanced > Customize Shortcuts menu

Multi-line Comments & Strings

Note that multi-line comments and strings are not subject to indentation rules! We did this to prevent formatting rules from getting in the way when you want to have a comment.

Bug Fixes

We constantly listen to feedback from the dev community and fix bugs as we find them. The following issues have been fixed based on developer feedback:

Script Editor - New Foundation and First Features - #90 by gillern

Script Editor - New Foundation and First Features - #48 by DataBrain

Script Editor - New Foundation and First Features - #67 by det3rr

Easy Script Switching

We wanted to make it easier to switch between scripts in Studio so now you can use Ctrl+Space on Mac (Ctrl+Tab on Windows) to easily cycle between Scripts and open tabs in Studio. They will be ordered by the most recently used script and you can change the shortcut through File > Advanced > Customize Shortcuts menu

Quickly Find Your Cursor

We’ve heard that it’s sometimes hard to find your cursor in the script editor, so we wanted to make that easier by highlighting the current line your cursor is on!

No more scrolling and moving around just to find the blinking cursor, now your current line is highlighted in light blue and you can customize it from File > Settings > Current Line Highlight Color


If you’d prefer, you can turn off this feature through File > Settings > Highlight Current Line


As always, please let us know if you have any feedback.

Thank you!


These awesome new features are brought to you by our super team:
@yohooyohoo @swmaniac @grant_xp @1ceF1y @iriszh @windy0724

229 Likes

This topic was automatically opened after 5 minutes.

These are all very nice; however, having the ability to easily close a function, loop, etc. without explicitly writing it after a paste/ modification would be nice. In Java, for example, if you paste in something (atleast in my IDE), if you then hit enter, it will correct any formatting (which studio basically does) but will also complete any unclosed lines of code which ultimately makes working much quicker than having to figure out where to properly close something or to move stuff around.

23 Likes

This is very cool I have to say might help me learn scripting faster and easier!:smiley: Can we get more features for building?

5 Likes

So happy to see so many great changes coming to the script editor. With how much time I spend in it, this really improves my development. The current line highlighted has been something I’ve been using for a monthish now, and it’s just amazing. Additionally, being able to copy and paste code without spaces is amazing! I can finally use code from the devfourm without taking 2 minutes to reformat it! Keep up the great work!

But who actually uses spaces for indenting? Why?

12 Likes

This is awesome! I’m excited for this, it will make inspecting minimized code easier as well as simply just formatting weirdly formatted code without having to manually do so (cough Discord code blocks).

3 Likes

Oh gee, more shortcuts to remember! I’m not complaining though!

Here’s what’s happening with the auto-indent thing when you undo (via keyboard shortcut and the button):

Don’t judge my code, I’m just starting with OOP wrapping!

Is this intended?

Regardless, I love the new improvements coming out recently, keep it up Roblox! :roblox: :roblox_light:

6 Likes

We still indent with Tabs by default (and this is recommended by Roblox), it’s just option to have more flexibility!

11 Likes

spaces are evil

although why was the hotkey changed? shift + tab worked fine. I am aware you can change it but what was the motive for changing the hotkey?

8 Likes

So uh now I can reformat my script instead of having to backspace/tab literally everything?

4 Likes

yes! when you paste code into editor, it will automatically do formatting for you. So when you press ctrl+z, it only undo the formatting.

4 Likes

Tab and Shift + Tab still work - it’s additional not instead of, to make it more like external editors. I far prefer Ctrl + [ and ]

7 Likes

Uh oh this will be annoying haha… I often speed write certain repetitive sections of code which obviously also utilizes a lot of copy pasting, and I end up hitting ctrl+z a TON. Hopefully this behaviour won’t stick around or I might end up turning format on paste off which will be unfortunate.

5 Likes

Cmd+Space is reserved for Spotlight Search on mac. Could you possibly change it to something else so it doesn’t conflict with the OS keyboard shortcuts?

EDIT: Cmd+Space is actually sunk by Spotlight Search, does not work for switching between scripts.

1 Like

Simply hit ctrl+z one more time to undo the paste as well.

2 Likes

I usually want my comments to follow indentation rules. Is there a setting for this I can turn on?

7 Likes

It would be cool to have game-level settings to change coding style so every scripter would use the same coding style. Now that there is an option to indent using spaces, there is a possibility of someone in a team changing that setting and messing up the indentation. At least I don’t want any space indentation in any of my code because spaces are evil.

btw a quick poll

  • Tabs
  • Spaces

0 voters

5 Likes

Shift+Tab and Tab are still work as usual! we just provide extra hot-key (ctrl+[/]) to give you another options.

3 Likes

Yeah I see it now, just that, the way it is worded it looks like the hotkey was replaced, but thank you and @BanTech for clarifying

1 Like