Suggested Keyboard Shortcuts

I love that Defold has it’s own built-in code editor, but with it being the place I spend the most time when making my game, I have some suggestions as to some quality-of-life improvements in the code editing experience.

My most dire suggestion is this:

In the original editor, holding Ctrl while pressing a left or right arrow key simply launches you to the beginning or end of the line.

Now in VS Code:

It selects the next whitespace delimited token.

Other suggestings I have include multi-cursor support and moving lines of code up and down by holding a key like Alt and using the up or down arrow key.

In general, I think VS Code is a pretty great reference for how good code editing feels, at least in my opinion. This is a pretty great resource for other functionality I would personally find helpful.

2 Likes

We do have some improvements planned for the code editor in coming sprints based on a workshop we had with developers in one of our studios. Some of the things you mentioned was brought up. @mats.gisselson and @vlaaad can tell you more.

1 Like

Regarding Ctrl ← and Ctrl → that goes to beginning/end of line — this is a behavior from macOS, and I think we should respect current OS behavior in this regard and use it to jump by words. Jumping by words currently exists in code editor as Alt ← and Alt →, which is also macOS-specific.

3 Likes

Yes, I agree we should revise the default shortcuts to be more in line with OS expectations.

As for multiple cursor support, it is already implemented. You can place additional cursors by holding a modifier key, but the more common use case is to use the Split Selection Into Lines and Select Next Occurrence commands (keyboard shortcuts are in the Edit menu). Or you could Alt-drag a box selection to quickly extend a column of cursors.

2 Likes

I use it all the time in PyCharm, but I never use it in Defold simply because it takes to long to carefully put out cursors.

Case in point, adding cursors in middle of a word (after DIR):

Defold (click them out or use split to lines)

click them out… (quicker to simply copy paste stuff then)
multicursor_defold

PyCharm (middle mouse button + drag)

multicursor


I would also like to have things like

Moving line of code (alt+Up/Down)

reorder

Cut (ctrl+x)

cut

Duplicate (ctrl+d)

duplicate

5 Likes

Apart from CMD+D to select next occurrance, I’d personally like (from Sublime&VSCode):

  • CTRL+CMD+G to select ALL occurrances (doesn’t move selection focus)
  • CTRL+CMD+ UP/DOWN to start adding to the multi cursor selection

Alt + drag does the same as Middle Button + drag does in PyCharm, although VSCode seems to have adapted the Middle Button drag too, so perhaps we should as well.

I would also like to encourage you to try using Ctrl + D (or Command + D on Mac) to select next occurrences. This is my favorite feature from Sublime Text, and is also implemented in VSCode and Atom. PyCharm does it too, but the default shortcut is different. Basically you’d select the ".DIR_" bit on the first line and just hold down Ctrl + D to select all of them without touching the mouse.

6 Likes

Ehhhhh?! How come I have missed this :scream: I thought you had to “cmd + click” them out (which is quite buggy and you can’t be too fast doing it).

3 Likes

Oh wow, I am so glad I posted this. I just did not notice those things existed. XD Thanks all.

4 Likes

Whoa…that alt-drag thing is awesome.


Pleeeeeaaaaase fix the Alt vs Ctrl thing for windows!!! Every. Single. Other. program on windows uses Control, including the other parts of the Defold editor, then suddenly it sends your cursor flying to the end or the start of the line when you try to select some code. #1 issue for me.

4 Likes

Yep, this is embarassing. Was embarassing: we fixed it!

8 Likes

Also, Middle Button + drag now box-selects in the code editor.

9 Likes

Awesome!

I would also love if it worked to put a cursor the “end of the line”. In the gifs below I “middle mouse click and drag” in the far right.

Expected behavior

Put a cursor at end of text
pycharm

Current behavior

Moves the cursor
defold

4 Likes

It would also be good to have :slightly_smiling_face:

  • Ctrl + L or Shift + W for toggling local and world space
  • f2 to rename selected gameobject/node
3 Likes

I strongly second F2 to rename selected stuff in the editor.

1 Like