Advanced Line Range SelectionAdvanced Line Range Selection is a focused Visual Studio Code extension for selecting exact text ranges using human-readable line coordinates. It supports:
InstallationInstall Advanced Line Range Selection from the Visual Studio Code Extensions view, or use:
To uninstall it:
Command
The normal UI entry points are available when a text editor has focus. UsageRun Advanced Line Range Selection: Select Line Range and enter either one line specifier or a start/end pair. A line specifier has one of these forms:
For A complete input is:
The two specifiers are separated by whitespace. The
Basic examplesThe following examples assume the default
When the end specifier is omitted entirely, the selection extends to the end of the document. Input SyntaxLine numbersA line number is a non-zero signed integer:
Leading zeros are allowed:
Zero is invalid:
Negative line numbers count backward from the end of the document:
After negative indexing is resolved, out-of-bounds line numbers are clipped to the document. Integer
|
| Value | Behavior |
|---|---|
nearest |
Select the nearest grapheme boundary. Equal-distance ties select the boundary after the requested position. |
before |
Select the nearest grapheme boundary at or before the requested position. |
after |
Select the nearest grapheme boundary at or after the requested position. |
The default is:
"advanced-line-range-selection.proportionSnap": "nearest"
If the requested position effectively matches an existing grapheme boundary, that boundary is used regardless of the snapping mode.
An empty line has only one boundary, so every proportional position resolves to that boundary.
Omitted Secondary Positions
A line specifier does not need a character, column, or proportional position.
For example:
13 20
contains two line-only specifiers.
An omitted secondary position is resolved only after the selection direction is known.
For a forward selection:
- omitted start position -> beginning of the start line;
- omitted end position -> end of the end line.
For a backward selection:
- omitted start position -> end of the start line;
- omitted end position -> beginning of the end line.
This makes line-only ranges symmetric:
13 20
and:
20 13
select the same text with opposite selection directions.
When both resolved line numbers are the same and at least one endpoint does not provide a usable explicit target, the selection is treated as forward.
Selection Direction
Direction is determined after line numbers and explicit secondary positions have been resolved.
The rules are:
- If the resolved start line is before the resolved end line, the selection is forward.
- If the resolved start line is after the resolved end line, the selection is backward.
- If both resolved lines are the same and both endpoints have explicit usable targets, their positions within the line determine the direction.
- Equality is considered forward.
- If both resolved lines are the same and either endpoint has no usable explicit target, the selection is forward.
Character targets and boundary targets can be mixed on the same line.
Their ordering follows:
line start
character 1
boundary after character 1
character 2
boundary after character 2
...
line end
This allows character coordinates and boundary-based column or proportional positions to determine direction consistently.
The first resolved endpoint becomes the VS Code selection anchor. The second becomes the active endpoint.
Empty Lines
An empty line contains zero grapheme clusters but still has one grapheme boundary.
The coordinate types behave as follows:
- character mode has no valid explicit character;
- column mode has exactly one valid column, column
1; - every proportional position resolves to the line's only boundary.
If an explicit character coordinate resolves to an empty line, there is no character to target. That endpoint is therefore treated like an omitted secondary position.
If both final VS Code positions are identical, the command performs no selection change.
A completely empty document is handled by the same rules.
Input Validation
Interactive use employs a managed VS Code input box with separate live validation and strict acceptance.
Live validation
As you type, the extension distinguishes between:
- complete valid input;
- incomplete input that can still become valid;
- structurally invalid input.
Incomplete input uses informational guidance such as:
Keep typing...
rather than an error state.
Strict acceptance
Pressing Enter only accepts input that matches the complete grammar.
Leading and trailing whitespace are ignored.
Leading zeros are accepted for non-zero integer components:
005
+005
005:003
005:-003
The following integer forms are invalid:
0
+0
-0
5:
Zero is valid in proportional syntax:
5.0
A bare proportional dot is also complete input:
5.
Programmatic Invocation
The command can also be invoked directly with a range string.
When a string argument is supplied, the command skips the input box and sends the string through the same parser and range-resolution logic used by interactive input.
For example, another extension can invoke:
await vscode.commands.executeCommand("advanced-line-range-selection.selectLineRange", "13:2 20.75");
A keybinding can also pass a fixed range:
{
"key": "ctrl+alt+r",
"command": "advanced-line-range-selection.selectLineRange",
"args": "13:2 20.75",
"when": "editorTextFocus"
}
If no argument is supplied, the normal interactive input box is shown.
If the supplied argument is not a string, or if the string does not match the accepted input grammar, the command performs no selection change.
Programmatic invocation operates on the current active text editor. If there is no active text editor, the command returns without making a change.
Configuration
Coordinate mode
Setting:
advanced-line-range-selection.coordinateMode
Default:
character
Available values:
| Value | Meaning |
|---|---|
character |
: numbers identify 1-based grapheme characters. Explicit character endpoints are inclusive. |
column |
: numbers identify 1-based grapheme boundaries. |
Proportional snapping
Setting:
advanced-line-range-selection.proportionSnap
Default:
nearest
Available values:
| Value | Meaning |
|---|---|
nearest |
Snap to the nearest grapheme boundary; ties snap after. |
before |
Snap to the nearest boundary at or before the requested position. |
after |
Snap to the nearest boundary at or after the requested position. |
Both settings are resource-scoped.
Keyboard Shortcut
| Platform | Shortcut |
|---|---|
| Windows / Linux | Ctrl+[ then Ctrl+] |
| macOS | Cmd+[ then Cmd+] |
The shortcut is active when a text editor has focus.
Other Ways to Run the Command
The command is also available from:
- Command Palette ->
Advanced Line Range Selection: Select Line Range - Editor context menu ->
Select Line Range
The editor context-menu entry is placed in the selection group.
Requirements
- Visual Studio Code
1.68.0or later.
The extension has no external runtime dependencies.
Development
Install development dependencies:
npm install
Package the extension:
npm run package
Publish the current version:
npm run publish
The package manifest also provides semantic-version publishing scripts:
npm run publish:patch
npm run publish:minor
npm run publish:major
Publishing requires the normal Visual Studio Marketplace publisher credentials and vsce authentication.
Repository
License
This project is licensed under the MIT License.
See LICENSE for details.
Author
- Name: Or Fadida
- Email: or@fadida.net
- GitHub: orfadida2000
- Marketplace: orfadida