diff --git a/plugins/vi-mode/README.md b/plugins/vi-mode/README.md index 6e781f296..bc78cfa3d 100644 --- a/plugins/vi-mode/README.md +++ b/plugins/vi-mode/README.md @@ -46,7 +46,7 @@ hasn't been defined by theme, *Insert mode* is not displayed by default. You can change these indicators by setting the `MODE_INDICATOR` (*Normal mode*) and `INSERT_MODE_INDICATORS` (*Insert mode*) variables. -This settings support Prompt Expansion sequences. For example: +These settings support Prompt Expansion sequences. For example: ```zsh MODE_INDICATOR="%F{white}+%f" @@ -157,6 +157,27 @@ NOTE: delete/kill commands (`dd`, `D`, `c{motion}`, `C`, `x`,`X`) and yank comma (`y`, `Y`) will copy to the clipboard. Contents can then be put back using paste commands (`P`, `p`). +## Text objects + +Standard text objects are supported with `i` ("inside") and `a` ("around"), e.g., for words; thus, you can select the word the cursor is in with `viw`, or delete the current word, including surrounding spaces, with `daw`. + +For other text objects, you can rely on the built-in functionality of Zsh and enable it accordingly. +For example, for quoted strings, you can copy the commented snippet of : place this in your `.zsrhc` file, e.g., after sourcing oh-my-zsh: + +```sh +autoload -U select-quoted +zle -N select-quoted +for m in visual viopp; do + for c in {a,i}{\',\",\`}; do + bindkey -M $m $c select-quoted + done +done +``` + +Now, in normal mode, you can select everything inside a double-quoted string with `vi"`. +Note that this works even if you're not already inside a quoted string. +For example, you can replace everything inside a single-quoted string in the current line, from wherever the cursor is, with `ci'`. + ## Known issues ### Low `$KEYTIMEOUT`