[TIPS] Code folding in Godot 3's script editor

[TIPS] Code folding in Godot 3's script editor



Views:4115|Rating:5.00|View Time:3:50Minutes|Likes:85|Dislikes:0
You can fold blocks of code in Godot 3! It’s more than a cosmetic change: it offers a convenient way to select, remove and move large chunks very easily.
—-
The Godot 3 course (early access) is on
Free Godot tutorials:
Free tutorial sources on Github:

This video is supported by:
– Gamblify:
– Pineapple Works:
– Echo86:

Subscribe for more tutorials!

Twitter ►

since the beta of good at three you can toggle blocks of code fold it to do this you place your cursor on the first line of a block and press alt F it's going to fold it if you have beta 2 or something more recent it's the same shortcut toggles the folded State you can press alt f2 unfold it it works on any block of code you place your cursor at the start and press alt F this is really cool for people who work on tutorials and video screencasts or teachers because you can hide some information this way you can add some code to the project and really focus just on the part that people need to learn or should care about now on top of that there are two unassigned shortcuts by default to fold everything and unfold everything let's see how to add them in go in the editor menu editor settings and the shortcuts tab look for fold to find the fold on lines and unfold all lines shortcuts the by default these are empty like so click on the pencil icon to set one and shift alt F to fold on lines for me and shift alt you to unfold all lines this is more than a cosmetic change by the way it helps us manipulate code on top of giving us a map or a quick overview of our code structure so if I press shift alt F you'll see I get all my methods in the script folded it's the same as having them on the bottom left and the map that we had down there but the one difference is that now if you place your cursor above a block and you do shift down twice you actually select the entire block you can see I went from line 55 to 88 if I cut this I've cut 30 lines at once and I can move my function down when I paste it will unfold like it did just now so this is a great way to move a block of code if you want to move a block inside a function or something it's a little more tricky if you have lines connected right next to it and you have this block folded for example if you do shift down like this and you try to cut all to move the block you will see it takes the last line the idle here which I don't want so the solution to avoid this is to add a line between the block you want to move or cut and the next block then you can do that you can shift and go down press control X for instance to cut the block or you can use alt down to only move that block when you have two lines like these and it may be worth instead to not fold it but select it directly at me recenter the screen on this but when you have a longer one like the jump for example it's worth adding a line and take grabbing everything just using the folded block there you go it's it's a pretty interesting addition I know that a lot of you requested it and I think the guy was yawn who added it anyway big thanks it's always pleasant had this

8 Replies to “[TIPS] Code folding in Godot 3's script editor”

  1. kurri sudarshan reddy

    Can you make a tutorial on how to upload a file to server in GoDot using gdscript didn't find much help in online

  2. Sébastien Dionne

    C'est une feature qui est rendu obligatoire dans les IDE maintenant. Prochaine étape, l'auto-complete sur les variables ? Ca serait pratique.

  3. MrSensitiveNipples

    When you create a function, what are the brackets for? Example: func move():
    And why do some functions have and underscore? Example: func _ready():

  4. MrSensitiveNipples

    Why do many game programmers start programming what's going to happen when the character that their programming dies/when the game ends. For example: One of their first functions that they create in their program is – onGameEnd(): or something similar like – onDeath():

Leave a Reply

Your email address will not be published. Required fields are marked *