"Move Line(s) of Text Up/Down" keyboard shortcut for Script Editor

You probably know what I mean if you’ve used other code editors, but if you don’t, many code editors now have a keyboard shortcut which lets you “move” the currently selected lines of text up / down “through” the source code. For instance, if you have the following:

foo
[BAR
BAZ] -- selected text
qux
quux

Then, if you press the “move down” shortcut, you would get (with the text still selected):

foo
qux
[BAR
BAZ] -- selected text
quux

Typically the shortcut is for this is some key combination + Up/Down arrow (Ctrl+Shift+Up/Down in SublimeText, Alt + Up/Down in VSCode, Alt+Shift+Up/Down in Intellij, etc…)

By using a combination of Shift, arrow keys, and the shortcut to select, move through, and edit a section of code this shortcut allows you to very quickly reorder a set of lines if you decide that they’re in the wrong order, which is normally a frustrating operation that requires manually cutting and pasting lines of code.

If you haven’t had the pleasure of using this shortcut before, trust me, it’s incredibly useful and versatile, and should definitely be included in the Studio Script Editor.

19 Likes

I looked at the example and didn’t find this feature useful, until I read the second to last paragraph.

Support!

1 Like

I use this feature all the time. I made a plugin called RbxSync that lets you use any third-party editor to edit Roblox scripts. This means that you can have this feature and other things like multiple cursors by using any editor you want and editing scripts is a simple alt+tab instead of a double click.

It’d still be great to have this natively, but I thought I’d throw this out there in case anyone wants these features right now! :smiley:

1 Like

I actually tired to do just that many years ago, but by straight up injecting the text directly the Roblox process memory instead (I put a “fingerprint” comment at the start of the scripts to be edited so that I could sniff out where the script’s source memory block was in memory, obviously not very practical in the end and I never ended up getting it to a usable state).

But, holy moly, why didn’t I think of the possibility of using HTTPService to pipe the changes in and out after GetAsync was added? Your implementation looks really solid too, very nice utility. I’ll try it out.

I still think that with the modern studio features (the code inference in particular, which works really well with the way that I tend to style my modules / classes), studio is probably better than using an external editor, so I’d still like this feature. It’s pretty much standard now (I can’t think of another modern code editor that doesn’t have it), so it should really be included.

1 Like

Losing the Studio autocomplete features is definitely the biggest trade-off for me. I’ve thought about making a plugin for a specific editor (perhaps Visual Studio Code) so that game tree and instance information could be sent, picked up by the IDE, and loaded into their IntelliSense panel. I haven’t really looked into it though, especially because it would only be useful to the subset of users who use that specific editor instead of being editor-agnostic.

Not to mention that that intellisense is really hard to make. Doing normal intellisense (and having it continue to work even as you type with the code in a temporarily invalid state for instance) is hard enough and doing fuzzy intellisense is even harder than that.

But most importantly the reason it’s still nice to make something on Roblox in the first place is that I don’t have to deal with a bunch of external plugins, toolchains on top of other toolchains, and that sort of nonsense.

1 Like

I find myself constantly trying to move blocks of code up or down the script. I’ve seen this feature in other editors in the past, so I’d love to see it in studio’s editor. My life would become a lot easier, instead of spamming backspace and re-tabbing some of my code.

1 Like