diff options
| author | Lorenzo Bettini <lorenzo.bettini@gmail.com> | 2025-05-12 09:56:26 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-12 09:56:26 +0200 |
| commit | c34c1da736f4f162206e1153e66850788f3e2e16 (patch) | |
| tree | d1f374e28eb7bd02ea8782b5df8b7713fec50e90 /plugins/vi-mode | |
| parent | 3f8ea81b89cda583acea098c9b7353c295619d4d (diff) | |
| download | zsh-c34c1da736f4f162206e1153e66850788f3e2e16.tar.gz zsh-c34c1da736f4f162206e1153e66850788f3e2e16.tar.bz2 zsh-c34c1da736f4f162206e1153e66850788f3e2e16.zip | |
docs(vi-mode): explaination for text objects (#13116)
Diffstat (limited to 'plugins/vi-mode')
| -rw-r--r-- | plugins/vi-mode/README.md | 23 |
1 files changed, 22 insertions, 1 deletions
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 <https://sourceforge.net/p/zsh/code/ci/master/tree/Functions/Zle/select-quoted>: 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` |
