Add send: vichangemode to reedline config (#16327)

# Description
Allows custom bindings (non-chord) to send a `edit_mode: vi` mode change
via the new `ReedlineEvent::ViChangeMode`
Takes https://github.com/nushell/reedline/pull/932

# User-Facing Changes
You can now set bindings which change the Vi mode. (This still has the
same rules for defining the key-combination: Only modifiers and single
keys are supported)
To do so send a `vichangemode` event with the `mode` field to set
`normal`, `insert`, or `visual`

```nushell
$env.config.keybindings ++=
	[{
	    name: modechangetest
	    modifier: control
	    keycode: "char_["
	    mode: [vi_normal, vi_insert]
	    event: {send: vichangemode, mode: normal}
	}]

```
This commit is contained in:
Stefan Holderbach
2025-08-03 13:23:55 +02:00
committed by GitHub
parent 2c9f6acc03
commit dfbd98013d
3 changed files with 9 additions and 6 deletions

View File

@ -1047,6 +1047,10 @@ fn event_from_record(
ReedlineEvent::ExecuteHostCommand(cmd.to_expanded_string("", config))
}
"openeditor" => ReedlineEvent::OpenEditor,
"vichangemode" => {
let mode = extract_value("mode", record, span)?;
ReedlineEvent::ViChangeMode(mode.as_str()?.to_owned())
}
str => {
return Err(ShellError::InvalidValue {
valid: "a reedline event".into(),