Main UI Code Editor Keyboard Shortcuts

Now that OH3 Main UI has a Code editor for editing the Pages YAML, I am wondering if there’s an official list of keyboard shortcuts / shortcut keys for it.

The ones I know (due to similarities to VS Code) and I’m on OSX:

  • Cmd+X and Cmd+C without a selection would cut / copy the current line
  • Cmd+V paste
  • Cmd+[ and Cmd+] Outdent and Indent (works on a selection too)
  • Option+Shift then drag the mouse cursor vertically will create a vertical selection, the same as in VS Code. Very handy when inserting/deleting the same thing over multiple lines
1 Like

I’m on Linux mostly so Cmd and Option are not a thing. Also, most of these are universal. You can use them in any text editor, MS Word, while composing an email, or what ever.

Combo What it does
CTRL-X Cuts the selection, or the current line if no selection
CTRL-C Copies the selection, or the current line if no selection
CTRL-V Paste
Tab Indent
CTRL-] Indent (shift right)
CTRL-[ Unindent (shift left)
ALT-SHIFT-mouse drag or arrow keys Block Selection
CTRL-SPACE Complete the current word or open a list of options to complete the current word of code
CTRL-s Save
CTRL-r Run the rule
CTRL-z Undo
CTRL-y Redo
CTRL-a Select all
CTRL-d This may be a bug. It appears to delete the current line and also disable the Rule.
CTRL-BACKSPACE Delete to the beginning of the word
CTRL-DEL Delete to the end of the word
CTRL-U Move cursor to the last line

The above are just the ones I use and remember off the top of my head. I’m sure there are more. The only one I’m missing is a key combo to comment/uncomment out a selection of lines. The usual ones don’t work in the browser. The other missing (or I don’t know it) one is to jump to a specific line number.

But again, almost all of these are universal. They are not specifically implemented by the code editor in the browser and can be used almost everywhere you edit text.

Thanks Rich. Indeed most are standard shortcut keys, but I learned a few new things from your list.

At the moment, I do this by doing a “zero column” vertical selection first - like you said above “block selection”

Sometimes I noticed the web based editor became very sluggish/slow too. Not sure why.