Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ They are listed as follows:
| `modalEditor.setInsertMode` | - | Set to insert mode (and clear selections if `clearSelectionsOnInsertMode` is enabled) |
| `modalEditor.setNormalMode` | - | Set to normal mode |
| `modalEditor.setSelectMode` | - | Set to select mode |
| `modalEditor.setSelectionSearchMode` | - | Set to search-within-a-selection mode |
| `modalEditor.setCommandMode` | - | Set to command mode |
| `modalEditor.setKeys` | `string` | Change current key sequence without applying it. Value should be a js expression (useful for modifying unexecuted commands) |
| `modalEditor.gotoLine` | `number` | Go to the specified line |
Expand Down Expand Up @@ -192,12 +193,14 @@ Available cursor styles can be found [here](https://github.com/microsoft/vscode/

### Basics

There are 4 predefined modes (`normal`, `insert`, `select`, `command`) in this extension,
but you are free to add more modes.
There are 5 predefined modes (`normal`, `insert`, `select`, `selectionSearch`,
and `command`) in this extension, but you are free to add more modes.
Note that the mode name shouldn't start with underscore `_` as it is reserved for other config.

Keybindings can be defined for all modes except for insert mode,
because this extension will handle over to VS Code in insert mode.
Keybindings can be defined for all modes except for insert mode and
selection search mode. In insert mode this extension will handle over to
VS Code, whereas in selection search input is reserved to type in the
regular expression to search with.

Each key sequence can be prefixed with a number indicating the count.
The count value will be stored in the `CommandContext`,
Expand Down
45 changes: 45 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,22 @@
"command": "modalEditor.setCommandMode",
"title": "Modal Editor: Set mode to command"
},
{
"command": "modalEditor.setSelectionSearchMode",
"title": "Modal Editor: Set mode to search within a selection"
},
{
"command": "modalEditor.navigateToNextSelection",
"title": "Modal Editor: Navigate to next selection"
},
{
"command": "modalEditor.navigateToPreviousSelection",
"title": "Modal Editor: Navigate to previous selection"
},
{
"command": "modalEditor.unselectPrimarySelection",
"title": "Modal Editor: Unselect primary selection"
},
{
"command": "modalEditor.importKeybindings",
"title": "Modal Editor: Import keybindings"
Expand Down Expand Up @@ -176,6 +192,35 @@
"command": "modalEditor.setKeys",
"args": "_ctx.keys.substring(0, _ctx.keys.length-1)",
"when": "editorTextFocus && modalEditor.mode == 'command'"
},
{
"key": "backspace",
"command": "type",
"args": { "text": "\b" },
"when": "editorTextFocus && modalEditor.mode == 'selectionSearch'"
},
{
"key": "escape",
"command": "type",
"args": { "text": "\u001b" },
"when": "editorTextFocus && modalEditor.mode == 'selectionSearch'"
},
{
"key": "enter",
"command": "type",
"args": { "text": "\n" },
"when": "editorTextFocus && modalEditor.mode == 'selectionSearch'"
},
{
"key": "delete",
"command": "type",
"args": { "text": "\u007f" },
"when": "editorTextFocus && modalEditor.mode == 'selectionSearch'"
},
{
"key": "alt+,",
"command": "modalEditor.unselectPrimarySelection",
"when": "editorTextFocus && (modalEditor.mode == 'normal' || modalEditor.mode == 'select')"
}
],
"configuration": {
Expand Down
26 changes: 23 additions & 3 deletions presets/helix.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const recordChange = command => record(command, "change");
const recordMotion = command => record(command, "motion");

module.exports = {
// Common keybindings (except for insert mode)
// Common keybindings (except for insert and selectionSearch modes)
"": {
u: repeatable("undo"),
U: repeatable("redo"),
Expand Down Expand Up @@ -319,7 +319,17 @@ module.exports = {
},

// set to select mode
v: "modalEditor.setSelectMode"
v: "modalEditor.setSelectMode",

// enter selection search mode
s: "modalEditor.setSelectionSearchMode",

// navigate between selections
"(": "modalEditor.navigateToPreviousSelection",
")": "modalEditor.navigateToNextSelection",

// unselect primary selection (Alt+, platform dependent)
"≤": "modalEditor.unselectPrimarySelection"
},

select: {
Expand Down Expand Up @@ -398,7 +408,17 @@ module.exports = {
},

// set back to normal mode
v: "modalEditor.setNormalMode"
v: "modalEditor.setNormalMode",

// enter selection search mode
s: "modalEditor.setSelectionSearchMode",

// navigate between selections
"(": "modalEditor.navigateToPreviousSelection",
")": "modalEditor.navigateToNextSelection",

// unselect primary selection (Alt+, platform dependent)
"≤": "modalEditor.unselectPrimarySelection"
},

// Command mode
Expand Down
Loading