mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2025-06-21 10:07:50 +02:00
docs(vi-mode): explaination for text objects (#13116)
This commit is contained in:
parent
3f8ea81b89
commit
c34c1da736
@ -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
|
You can change these indicators by setting the `MODE_INDICATOR` (*Normal mode*) and
|
||||||
`INSERT_MODE_INDICATORS` (*Insert mode*) variables.
|
`INSERT_MODE_INDICATORS` (*Insert mode*) variables.
|
||||||
This settings support Prompt Expansion sequences. For example:
|
These settings support Prompt Expansion sequences. For example:
|
||||||
|
|
||||||
```zsh
|
```zsh
|
||||||
MODE_INDICATOR="%F{white}+%f"
|
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
|
(`y`, `Y`) will copy to the clipboard. Contents can then be put back using paste commands
|
||||||
(`P`, `p`).
|
(`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
|
## Known issues
|
||||||
|
|
||||||
### Low `$KEYTIMEOUT`
|
### Low `$KEYTIMEOUT`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user