All Topics

Multiple Selections

The editor and console in CodeRunner support multiple selections. This is useful when you need to make similar edits in more than one location simultaneously in a document.

Adding Selections with the Mouse

Normally when clicking or dragging, the current selection is moved to the new location, thereby maintaining a single selection. To instead toggle multiple selections, hold ⌃⇧ or or while clicking or dragging.

When holding and dragging the mouse, a rectangular block of text is selected across multiple lines.

Adding Selections with the Keyboard

As a general rule, keyboard shortcuts involving multiple selections use the modifier keys ⌃⇧.

Selecting Multiple Occurrences of a String Using Find

To select multiple occurrences of the selected string, use Find ‣ Find and Select Next (⌘E). This will set the find search string and thereby highlight all occurrences of the string in the document. The selected occurrences are highlighted in yellow. To iteratively add the next highlighted occurrence to the selection, you can repeatedly invoke Find ‣ Find and Select Next (⌘E). To add the previous highlighted occurrence to the selection, or deselect (skip) the latest one, use Find ‣ Find and Select Previous (⇧⌘E).

Renaming Variables and Functions

To quickly select all occurrences of the selected string in the document, use Find ‣ Find and Select All (⌃⌘E). Usually, the selected occurrences are highlighted in yellow. This means that a regular string search was performed. However, if the selected string refers to a code token, such as a variable or function name, all instances of this token are selected and highlighted in blue. This means that other occurrences of the string that do not refer to the same token are not highlighted. To instead highlight all literal occurrences of the selected text, repeat the command Find ‣ Find and Select All (⌃⌘E).

Single Selection

When you are done using multiple selections and want to return to the normal single selection mode, simply press or use Text ‣ Single Selection (⌃J). If you normally use to invoke code completion and multiple selections are set, you can invoke code completion using ⌃␣ or ⌥⎋.

Iterating Through Active Selections

Use Find ‣ Jump to Next Selection (⌘J) to jump to the current selection in the document. When multiple selections are set, use this key combination multiple times to iteratively jump to the next selection. Use Find ‣ Jump to Previous Selection (⇧⌘J) to jump to the previous selection. These key combinations are useful to quickly identify all the active selections in a document.