"statement spans multiple lines" / Script editor losing indentation (tab) in a copy/paste operation

I use Sublime Text 3 as editor and I copy/paste it to the internal Studio script editor.
This line of my code has a manual like break and correct indentation (6 tabs):

But when pasting the entire code to Studio, I get this result (not indented, it seems some tabs are lost)


  1. Open this 2 lines file in an external editor (like Sublime Text): indentation.lua (137 Bytes)
  2. Select all and Ctrl+C
  3. Open Studio, create a new script, select all, Ctrl+V

The initial tabs will be lost:


Everytime i copy and paste a piece of code next to else, it moves the line to the left and doesn’t match the else line in spaces.

I have actually noticed this happening today, but i am unsure if it has been happening for longer than today already.

I do not have issues with any other lines

Hi rickje139, thanks for reporting! Would you share more content of you code? what’s the code before else and what did you paste?

1 Like

Here you go!

I figured out that it isn’t exclusive to else and it always happens whenever there is an extra space added at the beginning of the function.

ohhh ok, so looks like this is expected. For absolute indentation, the code you paste will be reindented according to the code structure, so the place you paste code is suggested to indent 2 level. I will suggest to do format selection from line 3 - 7.

But this still happens even when the function is very big, i sometimes like having my code spaced a bit to the right.

Sometimes my code automatically spaces a bit to the right and i dont have the motivation to fix it all to the left, so i just keep it like that, but then it will always move pasted code to the left.

well, the spirit of absolute indent rule actually doesn’t expect user to do any manually indent by themselves, because editor should handle all of it! It indents according to the code structure, so it may looks weird if you are using absolute indent but still do some manually indent.

But I am still curious in what situation you still want to do manually indent after editor formatting

We are working on the multiple line statement indenting, thanks for reporting!

1 Like

Hey everyone, just let you know multi-line statement indentation has been supported. Enjoy coding!

1 Like

Thanks, however, it’s not preserving the original tabs when pasting a code, like described in OP.
For example, currently, if I copy (from an external editor) and paste a multi-line instruction with 6 tabs in the second line (as the original image in OP) and then paste it into the Studio Editor, it’s being transformed into 3 tabs, losing the original indentation.

We will give 1 extra indentation from the first line of multi-line statement if you just paste code after first line. If you paste code after second line which has been indented manually, editor should align to the second line.

For example:

Objeto.CFrame = CFrame.new(Vector3.new(Pos3D.X, Objeto.Position.Y, Pos3D.Y)) * 
                                    CFrame.Angles(0, math.rad(Item.OrientationY), 0) *
                                    |<- paste code here, editor will align with second line

The problem is simple: studio editor should preserve 100% of the pasted code, and it’s not happening. When a text is pasted, it should not be changed.

oh, how about turning off “Format on paste” from setting?

1 Like

This I didn’t know.
Now it’s perfect.
Thank you.