Selecting Text

A selection is a a block of text marked for further manipulation. Range selections cover text between two points in a buffer, and rectangular selections cover a rectangular area. Several chunks of text can be selected simultaneously.

Range Selection

Dragging the mouse creates a range selection from where the mouse was pressed to where it was released. Holding down Shift while clicking a location in the buffer will create a selection from the caret position to the clicked location.

Holding down Shift in addition to a caret movement key (Left, Up, Home, etc) will extend a selection in the specified direction.

Edit>Select All (shortcut: Control-A) selects the entire buffer.

Edit>More Selection>Select None (shortcut: Escape) deactivates the selection.

Rectangular Selection

Dragging with the Control key held down will create a rectangular selection. Holding down Shift and Control while clicking a location in the buffer will create a rectangular selection from the caret position to the clicked location.

Edit>More Selection>Rectangular Selection toggles keyboard rectangular selection mode. In this mode, commands that normally create range selections will create rectangular selections. A status bar indicator is shown when this mode is enabled.

Rectangular selections behave differently than range selections when text is inserted. If the text has more lines than the rectangular selection, the text insertion proceeds as if the rectangular selection was automatically resized to the appropriate height. If the text to insert has less lines than the rectangular selection, the lines are repeated as many times as necessary to fill the selection.

It is possible to select a rectangle with zero width but non-zero height. This can be used to insert a new column between two existing columns, for example. Such zero-width selections are shown as a thin vertical line.

Range selections and non-zero-width rectangular selections are deactivated after text is inserted, while zero-width rectangular selections are shifted horizontally. This makes them behave like a “tall caret”. For example, to insert a string at a specific column on a number of lines, select a zero width rectangle at that column, and type the desired string.

Rectangles can be deleted, copied, pasted, and operated on using ordinary editing commands. If necessary, rectangular selections are automatically filled in with whitespace to maintain alignment.

Rectangular selections can extend beyond the end of a line into “virtual space”. Furthermore, if keyboard rectangular selection mode is on or if the Control key is being held down, clicking beyond the end of a line will insert the appropriate amount of whitespace in order to position the cursor at the clicked location.

Note

Rectangular selections are implemented using character offsets, not absolute screen positions, so they might not behave as you might expect if a proportional-width font is being used or if soft wrap is enabled. The text area font can be changed in the Text Area pane of the Utilities>Global Options dialog box. For information about soft wrap, see the section called “Wrapping Long Lines”.

Multiple Selection

Edit>More Selection>Multiple Selection (keyboard shortcut: Control-\) turns multiple selection mode on and off. In multiple selection mode, multiple fragments of text can be selected and operated on simultaneously, and the caret can be moved independently of the selection. The status bar indicates if multiple selection mode is active; see the section called “The Status Bar”.

Various jEdit commands behave differently with multiple selections:

  • Commands that copy text place the contents of each selection, separated by line breaks, in the specified register.

  • Commands that insert (or paste) text replace each selection with the entire text that is being inserted.

  • Commands that filter text (such as Spaces to Tabs, Range Comment, Replace in Selection, and so on) behave as if each block was selected independently, and the command invoked on each in turn.

  • Line-based commands (such as Shift Indent Left, Shift Indent Right, and Line Comment) operate on each line that contains at least one selection.

  • Caret movement commands that would normally deactivate the selection (such as the arrow keys, while Shift is not being held down), move the caret, leaving the selection as-is.

  • Some older plugins may not support multiple selection at all.

Edit>More Selection>Select None (shortcut: Escape) deactivates the selection containing the caret, if there is one. Otherwise it deactivates all active selections.

Edit>More Selection>Invert Selection (shortcut: Control-E I) selects a set of text chunks such that all text that was formerly part of a selection is now unselected, and all text that wasn't, is selected.

Note

Deactivating multiple selection mode while multiple blocks of text are selected will leave the selections in place, but you will not be able to add new selections until multiple selection mode is reactivated.