"If" typing Shortcut MacOS

I cannot get this to work. MacOS Sequoia; Xojo 2025 r1.

Am I typing this wrong? Or misreading this. Does it work for others?

I love this little feature and have been using it for a while.

But I do just Shift+Return (no ⌘). That’s just the way it’s always been for me on macOS.

Not sure why the documentation says otherwise.
Xojo-shortcut

It works with Opt + Shift + Return or only Shift + Return.

1 Like

Had no idea this feature existed. Thanks for creating this thread and calling attention to it. Great little timesaver!

I always hated this shortcut because I’ve never intentionally used it, you can’t disable it, and I have a standard for closing if statements. :grimacing:

I have the opposite experience. Wanting and trying to use this feature a lot, but there are too many times where it won’t work, like when having a ā€œselect caseā€ statement around the ā€œifā€ block, the IDE often closes the ā€œifā€ with an ā€œend selectā€, even though there’s already an ā€œend selectā€ below.

I’m also angry when I want to close a loop while I’m at a single ā€œifā€ line and the IDE prefers to convert the single line to a block rather than closing the loop, like here:

for i as Integer=0 to 1
  if true then MessageBox "Test" 'Cursor here

Pressing shift-return will produce this:

for i as Integer=0 to 1
  if true then 
    MessageBox "Test"
  end if

While I wanted this:

for i as Integer=0 to 1
  if true then MessageBox "Test"
Next

So, because I’m using shift-return a lot, I’m often needing to undo and type the end of loop manually; I’d prefer the IDE to detect an inline ā€œifā€ and recognise it’s a valid statement not needing to be reformatted.

Whereas, for those of us who dislike inline If statements, I find this handy when reformatting free code acquired here on the forum or a public repo.

So it becomes a feature, not a bug :wink:

Agreed. But I’ve found if you move the cursor to the right location (like one line below what you don’t want changed, or where the Select or If should end), then it’ll work. Then, in most case it’ll close the correct statement, whether a comment line, a Select Case or For loops.

FWIW, the IDE doesn’t look downward in your code when trying to figure out what the correct end block needs to be, only up. So the fact that ā€œthere’s already an End Select below the cursorā€ is not even considered.

I do understand that it has trouble with if statements inside select blocks. I run into that from time to time as well.

2 Likes