Skip to content

New Xojo Code Editor Improvements

There are several Code Editor improvements in Xojo 2021 Release 2 that you might enjoy. Read on to learn more about them.

Line Numbering and the Gutter

Code Editor Line Numbering is now an IDE preference instead of a per-Code Editor preference. In the Preference (or Options) window, choose Coding and then turn on “Show line numbers in gutter” to enable line numbering on all Code Editors.

With Line Numbering enabled, the gutter area is a bit wider to show the line number. As you move the cursor around in the Code Editor, notice that the gutter highlights to indicate the line you are on. This can be very handy to help find where the cursor is in a busy method.

You can also now click on a line number in the gutter to select the entire line. This is helpful if you want to copy the entire line, but it is also a great way to make it a bit easier to study a particular line of code more carefully.

Code Folding

If you’ve not used it before, Code Folding allows you to collapse (or fold) code to help reduce clutter in the Code Editor. You do this by clicking on the small “-” indicator that appears to the left of a code block. When code is folded that indicator changes to a “+”, which you can click to make the code visible again. Folded code is never removed, it is just temporarily hidden.

In this release, we improved the “-“ and “+” indicators so that they show with a rounded rectangle to be a bit friendlier. The code folding line highlights are also now slightly less distracting.

Super Return

When you are on an incomplete line of code, you can press Shift-Return (also known as Super Return) to automatically provide some assistance. For example, start typing an If statement like this:

If True

and press Shift-Return after typing True. The Code Editor will fill in the “Then” and “End If” and put the cursor between them:

If True Then
  <-- Cursor here
End If

When you press Super Return with a For loop, not only is the Next added as it always was, but if you have an inline loop variable, then it is added to the Next as well. This can make it easier to match nested loops.

Although this was added in 2021 Release 1, you may also find this tip useful: Press Super Return on a comment line to start a new line with a comment.

Related to Super Return is Option Return or Control-Alt Return on Windows/Linux. When you press Option Return on a line, a new line is added with the code continuation character placed at the end of the current line.

In 2021 Release 2, when you press Option Return when inside quotes for a String, the string is completed and things are extended to the next line.

Other Improvements

The Project -> Go To Location feature lets you jump to a specific method in your project by typing the class and name, for example: CustomerDetailsWindow.LoadCustomers

In 2021 Release 2 you can now also add a line number to jump to a specific part of the code. This is great when asking someone else on the team to look at some code, especially in a lengthy method. You can do this by putting a “#” followed by the line number like this: CustomerDetailsWindow.LoadCustomers#15

Sometimes you want to get the text for a method signature, but don’t want to copy the entire method and all its code (which was what you previously got when you select a method in the Navigator and choose Copy). Now you can right-click on the method signature in the header of the Code Editor and choose “Copy signature” to copy the signature to the clipboard.

As usual, be sure to check out the full release notes for 2021 Release 2 as there are other cool things to find or download 2021 Release 2 and try it yourself!