2118d35e017eb8c599f3c25863c8263aca307541

Author
Marc Cornellà <marc.cornella@live.com>
Committer
Marc Cornellà <marc.cornella@live.com>
Date

Message

fix(vi-mode)!: add back edit-command-line key binding as 'vv' (#9573)

BREAKING CHANGE: the key binding to open an editor to edit the command line has
been moved from being `v` (press v once) to being `vv` (press v twice). Now, the
action for `v` is the default `visual-mode`, as is in Vim.

Fixes #9573

Diff

 1diff --git a/plugins/vi-mode/README.md b/plugins/vi-mode/README.md
 2index 41faf2de02df88365b2fecd16242145420d83218..b59d5f279618110004533cbdf4344975d7553d3b 100644
 3--- a/plugins/vi-mode/README.md
 4+++ b/plugins/vi-mode/README.md
 5@@ -60,6 +60,12 @@ NOTE: some of these key bindings are set by zsh by default when using a vi-mode
 6 - `/`      : Search backward in history
 7 - `n`      : Repeat the last `/`
 8 
 9+### Vim edition
10+
11+- `vv`     : Edit current command line in Vim
12+
13+NOTE: this used to be bound to `v`. That is now the default (`visual-mode`)
14+
15 ### Movement
16 
17 - `$`   : To the end of the line
18@@ -99,9 +105,5 @@ NOTE: some of these key bindings are set by zsh by default when using a vi-mode
19 - `C`           : Delete to the end of the line and start insert
20 - `r{char}`     : Replace the character under the cursor with {char}
21 - `R`           : Enter replace mode: Each character replaces existing one
22-- `x`           : Delete [count] characters under and after the cursor
23-- `X`           : Delete [count] characters before the cursor
24-
25-### Removed key bindings
26-
27-- `v`   : Edit current command line in Vim
28+- `x`           : Delete `count` characters under and after the cursor
29+- `X`           : Delete `count` characters before the cursor
30diff --git a/plugins/vi-mode/vi-mode.plugin.zsh b/plugins/vi-mode/vi-mode.plugin.zsh
31index e5b252d837d9e9e43eb4fdbed7177ba4a85019ff..0b11a6a7f4c748e0cb09df5b205bfe99c9e19db4 100644
32--- a/plugins/vi-mode/vi-mode.plugin.zsh
33+++ b/plugins/vi-mode/vi-mode.plugin.zsh
34@@ -64,6 +64,11 @@ zle -N zle-line-finish
35 
36 bindkey -v
37 
38+# allow vv to edit the command line (standard behaviour)
39+autoload -Uz edit-command-line
40+zle -N edit-command-line
41+bindkey -M vicmd 'vv' edit-command-line
42+
43 # allow ctrl-p, ctrl-n for navigate history (standard behaviour)
44 bindkey '^P' up-history
45 bindkey '^N' down-history