Iron’s Multi-Selection latch allows the user to make multiple edits simultaneously at all the selection and caret locations (when latched) or to apply edits only to the primary selection or caret (when unlatched).
In Iron, the user can cycle through each of the multi-selections one at a time, working with just the primary selection without affecting the other selections. Also valuable is being able to cancel carets and selections one at a time.
This is unlike any other text editor which offers only simultaneous editing at all the carets.
See the discussion below about the relationship between Selections and Carets: Are They Synonymous?
Technology no longer consists just of hardware or software or even services, but of communities. Increasingly, community is a part of technology, a driver of technology, and an emergent effect of technology.Howard Rheingold
There are four selection styles used in Iron: stream, column, line and a bare caret.
A stream selection starts from the anchor which is “dropped” when you hold down the Shift key and use the arrow keys to move the caret. Just think of the anchor as where a selection starts. The selection extends to wherever the caret is moved to. In a stream selection, the shape of the selection follows the contours of the sequential lines of text in the file.
Anchors aren’t normally displayed but they can be turned on using the Themes|Caret Rendering|Render Anchors menu option.
A column selection is a geographical block on the screen, a square or rectangular region where the anchor defines a corner and the primary caret defines the opposite corner. The primary caret and anchor can be exchanged, rather the primary caret can be moved to any of the four corners of the block and the anchor will move to the opposite corner.
Experiment with Ctrl+Shift+Arrow to move the caret up to the top of the block, to the bottom or to either of the left or right edges of the block. If the caret is already at the top, left, bottom or right edge and you arrow in that direction, the block will grow.
A column selection has multiple carets, one on each line of the block and they move in a vertical column as the primary caret moves left and right. This means a single column selection has multiple carets where inserting a character or deleting occurs on each line.
A line selection is also a geographical block, a rectangular region that extends from the left-most column infinitely to right to include the entire line. The anchor and primary caret define the top and bottom lines of the block. And like column selections, there is a caret on each line of the block.
In Iron Professional Mode, you can edit text without deleting the entire line and without canceling the selected lines.
Column and line selections allow the primary caret to move horizontally anywhere on the line, even past the last character on the line into virtual space. This is true whether Iron is in Virtual Space Editing mode or not. Stream selections always wrap to the adjacent line and never extend into virtual space. And that’s true whether using Virtual Space Editing mode or not.
The fourth selection style is a bare caret. It’s a bit of a technicality to think of a bare caret as a selection style given a bare caret isn’t selecting any text. It’s just a caret.
You can think of a bare caret as a null selection, a region of no area with an anchor that moves in conjunction with the primary caret.
Rather, think of a bare caret as a caret that hasn’t selected anything yet and once it does, the selection style changes from being a bare caret to being either a stream, column or line selection. Thus canceling a selection is simply changing the selection style to being a bare caret.
Selections and Carets: Are They Synonymous?
Nope, selections and carets are not the same thing. So how are they related?
One selection may have more than one caret as in the case of a column selection where there’s a caret on each line. This is the same for line selections, there’s a caret on each line. Stream selections have only one caret. (Stream selection is ubiquitous and the style you’re probably most familiar with.)
Though a single column selection has multiple carets, that is not a multi-selection. It is a single selection where you can make edits on multiple lines at the same time.
When you create a new selection, it starts either as a bare caret, a clone of the current (primary) selection or as a selection made by searching for a text string. Multi-selections don’t have to use the same selection style, they can be mix of line, column and stream selections and bare carets.
So what is a bare caret? Well, that’s a caret that doesn’t have anything selected yet. It’s just a caret.
Then what is a cloned selection? A cloned selection is a new selection created using the same style and with same width as the primary selection. It’s a one-line tall selection added to the multi-selection on the line just below (or above) the primary selection.
Why Our Multi-Selection is Better: The Latch
Iron’s Multi-Selection is better in these ways:
- The latch (Ctrl+Shift+Space) allows the user to apply edits to a single (primary) selection or to all multi-selections simultaneously.
- The user can change primary selections (Ctrl+Shift+N), make edits with just that one caret (when unlatched) and not affect any of the other multi-selections.
- Bare carets can be added one at a time (Ctrl+Shift+Enter).
- Selections can be canceled (ESC) one at a time.
- All selections can be canceled simultaneously (Ctrl+Shift+Delete).
- Selections can be added one at time using Keep & Find Another (Ctrl+Shift+F3).
- All instances of a search string can be added to a multi-selection (Ctrl+Shift+A).
- Selections can be cloned (Ctrl+Shift+Down_Arrow).
- Selection styles can be changed one at time or as a set (when latched).
- Selection anchors and carets can be exchanged (Ctrl+Shift+Arrow).
- Multi-selections can be alphabetically sorted (Ctrl+Shift+Q).
- Multi-selections can be re-ordered from top-to-bottom (Ctrl+Shift+R).
- A selection can be split into one-line multiple selections (Ctrl+Shift+M).
- Multiple selections can be combined into one selection (Ctrl+Shift+M again).
- Multi-selections can be undone (Ctrl+Z) and redone (Ctrl+Shift+Z).
- You can review multiple edits and make piecemeal corrections.
After finishing a simultaneous multi-selection edit, you can easily review each change one at a time by using the ESC key. The Multi-Selection latch (when toggled off using Ctrl+Shift+Space) allows you the flexibility to work with each selection independently and then continue reviewing the remaining edits.
That’s a review feature not available in other editors. And if you hold down the ESC key, it’s kind of fun to watch all the selections quickly cancel one at a time. This provides a quick, fun visual of where edits occurred. This also leaves the caret at the location where you started the multi-selection.
Being able to change primary selections, add or cancel one selection at a time, change selection styles in groups or singly, exchange the anchors and carets provides an incredible amount of multi-selection power.
Working with repetitive or nearly-repetitive source code becomes a breeze.
Multi-Selection (a.k.a. multi-editing, multiple carets)
Multi-Selection is one of Iron’s premier power-editing features.
Source code is repetitive by nature. Functions, methods, type declarations and variable names (identifiers) are declared and then referenced repeatedly throughout a software project. Chunks of code tend to be copied and re-used creating more repetition. This repetition creates an opportunity for increasing editing efficiency and programmer output.
As code evolves, the need to change names in bulk or insert the same text at multiple locations increases. Quickly re-utilizing and refactoring code is often the key to faster software development. Using Multi-Selection makes bulk changes much faster and easier.
The power of Multi-Selection may not be apparent to novice programmers. Most experienced programmers won’t work without it.
Iron’s Multi-Selection doubles as a dialog-less Find-and-Replace utility. More than just replacing text in multiple places simultaneously, you can use Multi-Selection to review changes quickly after the fact, one at a time, and correct them individually.
Multi-Selection allows you to setup multiple selections and then add an additional bare caret using Ctrl+Shift+Enter, unlatch with Ctrl+Shift+Space, then run off and make edits elsewhere with that bare caret. Once done editing elsewhere, use the ESC key once to cancel the bare caret and return to the previously defined selections.
Multi-Selection allows you to select columns, lines or streams of text and then copy them into the clipboard (scrap). The selections can be alphabetically sorted when they’re copied.
The importance and value of Multi-Selection is such that Iron’s default key mappings reserve the Ctrl+Shift modifier pair for multiple selection actions (sacrificing some traditional mappings).
Refer to the iron.keymap file for all the Multi-Selection actions. Some are list here:
Ctrl+Shift+Enter — add a new bare caret
Ctrl+Shift+Space — toggle the Multi-Selection latch
ESC — cancel the primary selection
ESC — cancel the primary caret
Ctrl+Shift+Delete — cancel all Multi-Selection carets and selections
Ctrl+Shift+Down/Down_Up — clone a selection region or caret below/above
Ctrl+Shift+N — cycle to the next caret/selection
Ctrl+Shift+P — cycle to the previous caret/selection
Ctrl+Shift+M — split into or combine multiple selections
Ctrl+Shift+Alt+Q — cut-to-scrap and alphabetically Quicksort
There are four selection styles: column, line, stream and none (just a bare caret). Column and line selections have a caret on each line in their block. The primary caret of a column selection is at one of the corners of the selected block of text. Stream selections (as normally used in other editors and operating systems) only ever have one caret associated with it.
There is also an anchor associated with a selection. There’s one per selection and it remains where the caret was when a selection is first started a.k.a. extended. There are Multi-Selection utilities to swap the caret and anchor positions (Ctrl+Shift+Arrow).
Note: In Iron, a bare caret is actually implemented as a selection with nothing selected. The anchor and caret of the selection stay colocated thus defining a null selection.
Important to keep in mind is the Multi-Selection latch. The latch can be toggled on and off using Ctrl+Shift+Space. When latched, any editing actions are applied to all the carets of all the selections. When unlatched, editing actions get applied to the primary bare caret or to carets on each line of the single primary selection.
The caret shape in some caret rendering modes will change based on the latch’s state. Selection highlighting will also use different colors to indicate the latch state. Line number highlighting indicates the line of primary caret of the primary selection. Anchors are not normally rendered.
The state of the latch is automatically changed by some Multi-Selection actions. For example, creating a new line selection with Ctrl+Shift+Down_Arrow (in Iron Professional Mode), the latch is switched on in this case as that’s more convenient once the desired lines have been selected and editing commences.
Selections, by the way, can overlap each other and be mixed in style. The Copy, Cut and Paste commands generally work as expected but since the creation order of the overlapping selections matters, the results of overlapped actions are not always intuitive. Though there are useful tricks, we suggest avoiding overlapped Multi-Selections, at least until you are proficient in their use.
When there are multiple selections, you can cycle through each selection one at a time using Ctrl+Shift+N or Ctrl+Shift+P. And using Ctrl+Shift+Arrow, any latched selection will move its caret(s) to the edge of the selection in the direction of the arrow (if not already there). Thus it’s possible to move the caret to any corner of a column selection without changing the dimension of the region selected. This is often quite handy. Latch states and actions of cycling through selections are preserved in the Undo System and can be undone and redone.
With practice using Multi-Selections, it becomes normal and second nature to select text and then create another caret, make changes elsewhere then cancel the caret and return to the old location without disturbing the other selections. Additionally useful is that bookmarks preserve selection regions and styles, not just a file location.
There are many editing tricks and shortcuts making use of Multi-Selection that will be demonstrated in video tutorials. Stay tuned, you’ll be surprised at all you can do with Multi-Selection.
We encourage both new and experienced programmers to experiment and learn how to use Multi-Selection and Virtual Space Editing. We think once you get the hang of it, you’ll be hooked and will never look back. And then, to become super-efficient, there’s Iron Professional Mode which employs a reduced set of key bindings and Sticky Selections.
To Find-and-Replace multiple instances of a text string within a single file, here are the commands to accomplish this using Multi-Selection:
F8 — toggle open the Command Palette
F3 — search again
Ctrl+Shift+F3 — keep and search again (create a Multi-Selection)
Ctrl+Shift+A — multi-select all instances of the search string
Ctrl+Shift+Alt+F3 — multi-select all instances of identifier near the caret
Ctrl+Shift+Space — toggle the Multi-Selection latch on or off
ESC — cancel a selection or one caret
Ctrl+Shift+Delete — cancel all selections and carets
Ctrl+Z — undo
Ctrl+Shift+Z — redo
Here are the few steps used to a Find-and-Replace using Multi-Selection:
- Open the Command Palette (F8), type the text to search for, press Enter.
- Use Ctrl+Shift+F3 to Keep and Find Another for additional instances of the text. This will keep all the previous multi-selections and create a new selection for next instance.
- Use F3 Find Next to search for the next instance. This does keep the current selection as part of the multi-selection set. This is how to skip an instance.
- Or use Ctrl+Shift+A to create a multi-selection of all instances of the search text.
- Once you’ve multi-selected the instances to change (the latch will have switched to on) just edit all the instances simultaneously. Undo and redo can be used, of course, while editing or searching instances.
- Or skip all the previous steps, place the caret on identifier to multi-select and press Ctrl+Shift+Alt+F3 to Keep & Find All Quick. You can also select text on a single line to use as the search pattern.
One nice feature of Iron’s Multi-Selection is that you can review, one at a time, each of your find-and-replace edits. Simply use the Escape key (ESC) to cancel a selection one at a time. If an instance was mistakenly changed, unlatch Multi-Selection with Ctrl+Shift+Space and make the correction with the unlatched primary caret. Then continue reviewing using the ESC key.
Typically after making multi-selection edits, it’s fun to press and hold the ESC key down to cancel all the selections and carets in a fast-motion review. It also takes to you the location of the first instance found. Or just use Ctrl+Shift+Delete to cancel all the selections and carets and remain where the last instance was found.
Note: Iron doesn’t have a separate Find-and-Replace dialog nor a way to perform a find-and-replace across multiple files. In the future, the Find-in-Files (FIF) function will provide a means to Find-and-Replace across multiple files.