How can I copy my code into a conditional, function, etc. and have the indentations go to the right place?

When copying my code from one place to another it is very frustrating because it does not stay in place, the indentations move from place to place. Is there any way to correct that in the editor? maybe a plugin or some video on how to do it in the most efficient way!

it doesnt auto align yeah
you can try block the code, then press either Tab Key on your keyboard to make it all indent to the right. Or Shift+Tab Key to make it indent to the left

If you know how to do that manually. The problem is that by having some conditionals nested inside each other, it becomes a problem to do it manually and time is wasted.

If you look at your selection in the video, prior to copying, your selection started at the start of the code (not including the tabs). You proceeded to paste the code by placing your cursor 3 tabs deep into your code. That is why it started at the wrong indent, you told it to.

As for the rest of the formatting, I used to do a lot of CSS and HTML work. When I discovered Prettifier in VSCode, my life changed. The most amazing tool ever! Copy and paste any mess of code and it instantly formatted it beautifully.

However, with JDScript, the majority of my time is NOT taking up by the trivial task of indenting things. It is taken up with reading the code, analysing the code, optimising the code, etc etc. The actual ‘typing’ or ‘tabbing’ is not the thing that takes up time.

However, one useful trick to help is to select all the code that is messy and use shift tab to bring it all to the right of the screen. It will be applied to all selected lines even if the lines are not fully selected (if that makes sense) (You may have to back tab a few times). Then select everything in the function and tab once to move it over. Then move through any blocks, selecting them and tabing them as well. Seriously, it took longer to write this post than it does to format an entire script.

PS One final tip. If you selected from the end of the previous line and down to the end of the line you wanted to copy, then selected the end of the line before where you wanted to paste, all the indents would be preserved perfectly. They may still not match your destination nesting, but easy then to tab them all accross or back in one go using shift tab or tab when multiple lines are selected.

I know it seems silly, and I understand that VSCode has shortcuts to organize the code, it is very practical. I come from JAVA and believe me I would pay for a plugin that would help me just copy and paste, anyway thanks

In that video, look where your cursor is when you paste. Your selection started at the end of the previous line (which is right), but you pasted into some tabs. Instead paste at the end of the line too.

PS Actually you selected to the beginning of the line when copying. I always start at the end of the previous line. Just habit I suppose.

GDScript is whitespace sensitive unlike JAVA, it cannot fix whitespace without changing how your code runs.

You can at least select multiple lines after pasting and press tab to add indentation to all the selected lines, and shift+tab to remove a indent from all selected lines.

@danieldigitalbo
I found something amazing that I thought you would be interested in.

When you cut and paste code with spaces into the editor, just use CTRL + SHIFT+ I (Capital i) and all the spaces become tabs!

I can’t believe I only just learned this - lol.

Hope you like it,

Paul