From 7de44dbdb767e52e509010b1468126259e0b8b87 Mon Sep 17 00:00:00 2001 From: Gabor Marton Date: Wed, 4 Feb 2015 12:56:58 +0100 Subject: Added trapwinch to vi-mode plugin. --- plugins/vi-mode/vi-mode.plugin.zsh | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'plugins/vi-mode') diff --git a/plugins/vi-mode/vi-mode.plugin.zsh b/plugins/vi-mode/vi-mode.plugin.zsh index 3ed32b3fb..f2745b409 100644 --- a/plugins/vi-mode/vi-mode.plugin.zsh +++ b/plugins/vi-mode/vi-mode.plugin.zsh @@ -14,6 +14,14 @@ function zle-keymap-select zle-line-init zle-line-finish { zle -R } +# Ensure that the prompt is redrawn when the terminal size changes. +TRAPWINCH() { + if [[ -o zle ]]; then + zle reset-prompt + zle -R + fi +} + zle -N zle-line-init zle -N zle-line-finish zle -N zle-keymap-select -- cgit v1.2.3-70-g09d2 From 099246dd9e74f7a2488fe7c51fe8c40502295def Mon Sep 17 00:00:00 2001 From: "Daniel Campoverde [alx741]" Date: Wed, 18 Feb 2015 14:25:15 -0500 Subject: PLUGINS: vi-mode: allow ctrl-p, ctrl-n for history navigation Allow ctrl-p, ctrl-n for history navigation while in insert mode. --- plugins/vi-mode/vi-mode.plugin.zsh | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'plugins/vi-mode') diff --git a/plugins/vi-mode/vi-mode.plugin.zsh b/plugins/vi-mode/vi-mode.plugin.zsh index f2745b409..45ec22a09 100644 --- a/plugins/vi-mode/vi-mode.plugin.zsh +++ b/plugins/vi-mode/vi-mode.plugin.zsh @@ -34,6 +34,10 @@ bindkey -v autoload -Uz edit-command-line bindkey -M vicmd 'v' edit-command-line +# allow ctrl-p, ctrl-n for navigate history (standard behaviour) +bindkey '^P' up-history +bindkey '^N' down-history + # if mode indicator wasn't setup by theme, define default if [[ "$MODE_INDICATOR" == "" ]]; then MODE_INDICATOR="%{$fg_bold[red]%}<%{$fg[red]%}<<%{$reset_color%}" -- cgit v1.2.3-70-g09d2 From 33900dfd328ea21954cc7772af21e5d44ea71f3f Mon Sep 17 00:00:00 2001 From: "Daniel Campoverde [alx741]" Date: Wed, 18 Feb 2015 14:29:44 -0500 Subject: PLUGINS: vi-mode: allow ctrl-h, ctrl-?, ctrl-w for char and word deletion Allow ctrl-h, ctrl-?, ctrl-w after changes in normal mode. --- plugins/vi-mode/vi-mode.plugin.zsh | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'plugins/vi-mode') diff --git a/plugins/vi-mode/vi-mode.plugin.zsh b/plugins/vi-mode/vi-mode.plugin.zsh index 45ec22a09..1de8bf91a 100644 --- a/plugins/vi-mode/vi-mode.plugin.zsh +++ b/plugins/vi-mode/vi-mode.plugin.zsh @@ -38,6 +38,11 @@ bindkey -M vicmd 'v' edit-command-line bindkey '^P' up-history bindkey '^N' down-history +# allow ctrl-h, ctrl-w, ctrl-? for char and word deletion (standard behaviour) +bindkey '^?' backward-delete-char +bindkey '^h' backward-delete-char +bindkey '^w' backward-kill-word + # if mode indicator wasn't setup by theme, define default if [[ "$MODE_INDICATOR" == "" ]]; then MODE_INDICATOR="%{$fg_bold[red]%}<%{$fg[red]%}<<%{$reset_color%}" -- cgit v1.2.3-70-g09d2 From bc8abe5ea26aa031395c754e3e9710dcc62dd0f0 Mon Sep 17 00:00:00 2001 From: Brian Derr Date: Thu, 19 Feb 2015 13:30:50 -0800 Subject: Verify zle is active before trying to reset-prompt. --- plugins/vi-mode/vi-mode.plugin.zsh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'plugins/vi-mode') diff --git a/plugins/vi-mode/vi-mode.plugin.zsh b/plugins/vi-mode/vi-mode.plugin.zsh index f2745b409..ac9233290 100644 --- a/plugins/vi-mode/vi-mode.plugin.zsh +++ b/plugins/vi-mode/vi-mode.plugin.zsh @@ -17,8 +17,12 @@ function zle-keymap-select zle-line-init zle-line-finish { # Ensure that the prompt is redrawn when the terminal size changes. TRAPWINCH() { if [[ -o zle ]]; then - zle reset-prompt - zle -R + # Verify that zle is active before trying to reset-prompt. + zle + if [[ $? -eq 0 ]]; then + zle reset-prompt + zle -R + fi fi } -- cgit v1.2.3-70-g09d2 From d7837c6041b1099982e3f278b50e8868b8b30ff9 Mon Sep 17 00:00:00 2001 From: Brian Derr Date: Sat, 21 Feb 2015 18:08:54 -0800 Subject: Shorten the zle check and reset-prompt into one line. --- plugins/vi-mode/vi-mode.plugin.zsh | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'plugins/vi-mode') diff --git a/plugins/vi-mode/vi-mode.plugin.zsh b/plugins/vi-mode/vi-mode.plugin.zsh index ac9233290..80df97d61 100644 --- a/plugins/vi-mode/vi-mode.plugin.zsh +++ b/plugins/vi-mode/vi-mode.plugin.zsh @@ -16,14 +16,7 @@ function zle-keymap-select zle-line-init zle-line-finish { # Ensure that the prompt is redrawn when the terminal size changes. TRAPWINCH() { - if [[ -o zle ]]; then - # Verify that zle is active before trying to reset-prompt. - zle - if [[ $? -eq 0 ]]; then - zle reset-prompt - zle -R - fi - fi + zle && { zle reset-prompt; zle -R } } zle -N zle-line-init -- cgit v1.2.3-70-g09d2 From 0e35bd4001494782fb1956acaebadf2f81c25b42 Mon Sep 17 00:00:00 2001 From: "Daniel Campoverde [alx741]" Date: Sun, 29 Mar 2015 00:12:58 -0500 Subject: Plugins: vi-mode: Add first README file --- plugins/vi-mode/README.md | 75 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 plugins/vi-mode/README.md (limited to 'plugins/vi-mode') diff --git a/plugins/vi-mode/README.md b/plugins/vi-mode/README.md new file mode 100644 index 000000000..03e67cca2 --- /dev/null +++ b/plugins/vi-mode/README.md @@ -0,0 +1,75 @@ +vi-mode +======= +This plugin increase `vi-like` zsh functionality. + +Use `ESC` or `CTRL-[` to enter `Normal mode`. + + +History +------- + +- `ctrl-p` : Previous command in history +- `ctrl-n` : Next command in history +- `/` : Search backward in history +- `n` : Repeat the last `/` + + +Mode indicators +--------------- + +*Normal mode* is indicated with red `<<<` mark at the right prompt, when it +wasn't defined by theme. + + +Vim edition +----------- + +- `v` : Edit current command line in Vim + + +Movement +-------- + +- `$` : To the end of the line +- `^` : To the first non-blank character of the line +- `0` : To the first character of the line +- `w` : [count] words forward +- `W` : [count] WORDS forward +- `e` : Forward to the end of word [count] inclusive +- `E` : Forward to the end of WORD [count] inclusive +- `b` : [count] words backward +- `B` : [count] WORDS backward +- `t{char}` : Till before [count]'th occurrence of {char} to the right +- `T{char}` : Till before [count]'th occurrence of {char} to the left +- `f{char}` : To [count]'th occurrence of {char} to the right +- `F{char}` : To [count]'th occurrence of {char} to the left +- `;` : Repeat latest f, t, F or T [count] times +- `,` : Repeat latest f, t, F or T in opposite direction + + +Insertion +--------- + +- `i` : Insert text before the cursor +- `I` : Insert text before the first character in the line +- `a` : Append text after the cursor +- `A` : Append text at the end of the line +- `o` : Insert new command line below the current one +- `O` : Insert new command line above the current one + + +Delete and Insert +----------------- + +- `ctrl-h` : While in *Insert mode*: delete character after the cursor +- `ctrl-w` : While in *Insert mode*: delete word after the cursor +- `d{motion}` : Delete text that {motion} moves over +- `dd` : Delete line +- `D` : Delete characters under the cursor until the end of the line +- `c{motion}` : Delete {motion} text and start insert +- `cc` : Delete line and start insert +- `C` : Delete to the end of the line and start insert +- `r{char}` : Replace the character under the cursor with {char} +- `R` : Enter replace mode: Each character replaces existing one +- `x` : Delete [count] characters under and after the cursor +- `X` : Delete [count] characters before the cursor -- cgit v1.2.3-70-g09d2