line_commands
This directory defines a standard set of line-level editing, selection, and navigation commands for Talon. By utilizing the user.line_commands tag, these commands can be consistently enabled across various text editors and IDEs.
The directory contains two main files that work together to establish these capabilities:
- line_commands.py – Declares the Talon tag and defines the underlying Python actions.
- line_commands.talon – Maps voice commands to both native Talon actions and the custom actions defined in the Python file.
How It Works
The functionality is split into declaration, implementation, and voice mapping:
Tag Declaration and Action Definitions
The line_commands.py file registers the line_commands tag inside the user namespace. It also exposes several actions designed to be overridden by context-specific scripts (such as those for VS Code, JetBrains, or other advanced editors) or used directly via fallback implementations.
For instance, the action select_range(line_start, line_end) is fully implemented using standard editor keyboard shortcuts:
- Jumps to the starting line using
edit.jump_line(). - Extends the selection to the end of that line.
- Iteratively extends the selection downward to cover the specified range.
Other actions, such as extend_camel_left() or camel_right(), serve as interface declarations (placeholders) that individual IDE integrations implement to leverage native IDE APIs for subword (camelCase) movement.
Voice Command Mappings
The line_commands.talon file is activated when the user.line_commands tag is enabled. It links spoken phrases to action sequences, providing a powerful vocabulary for editing code and structured text.
Here is a summary of the core command groups defined in the voice file:
- Line Navigation: Commands like
go <number>andgo <number> endallow you to instantly teleport your cursor to a specific line or the end of a specific line. - Range Selection and Manipulation: Commands such as
clear <number> until <number>,copy <number> until <number>, orcomment <number> until <number>leverage theuser.select_range()action to perform batch actions across multiple lines cleanly. - Indentation and Ordering: You can adjust indentations (e.g.,
tab <number> until <number>orretab that) or move blocks of text up and down (e.g.,drag down <number> until <number>) to reorder code blocks. - Subword Navigation: Commands like
go camel leftorselect camel rightfacilitate precise positioning within concatenated words (such as camelCase or snake_case identifiers) using the subword actions declared in line_commands.py.