Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
oh-my-zsh
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
github
oh-my-zsh
Commits
e0f92c8d
Unverified
Commit
e0f92c8d
authored
Mar 07, 2023
by
Julien Vincent
Committed by
GitHub
Mar 07, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(vi-mode): add settings for vi-mode cursor styles (#10860)
parent
d342b353
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
7 deletions
+37
-7
README.md
plugins/vi-mode/README.md
+21
-0
vi-mode.plugin.zsh
plugins/vi-mode/vi-mode.plugin.zsh
+16
-7
No files found.
plugins/vi-mode/README.md
View file @
e0f92c8d
...
...
@@ -29,6 +29,8 @@ plugins=(... vi-mode)
VI_MODE_SET_CURSOR=true
```
See [Cursor Styles](#cursor-styles) for controlling how the cursor looks in different modes
- `MODE_INDICATOR`: controls the string displayed when the shell is in normal mode.
See [Mode indicators](#mode-indicators) for details.
...
...
@@ -52,6 +54,25 @@ INSERT_MODE_INDICATOR="%F{yellow}+%f"
You can also use the `vi_mode_prompt_info` function in your prompt, which will display
this mode indicator.
## Cursor Styles
You can control the cursor style used in each active vim mode by changing the values of the following variables.
```
zsh
# defaults
VI_MODE_CURSOR_NORMAL=2
VI_MODE_CURSOR_VISUAL=6
VI_MODE_CURSOR_INSERT=6
VI_MODE_CURSOR_OPPEND=0
```
- 0, 1 - Blinking block
- 2 - Solid block
- 3 - Blinking underline
- 4 - Solid underline
- 5 - Blinking line
- 6 - Solid line
## Key bindings
Use `ESC` or `CTRL-[` to enter `Normal mode`.
...
...
plugins/vi-mode/vi-mode.plugin.zsh
View file @
e0f92c8d
...
...
@@ -14,6 +14,15 @@ typeset -g VI_MODE_RESET_PROMPT_ON_MODE_CHANGE
# Unset or set to any other value to do the opposite.
typeset
-g
VI_MODE_SET_CURSOR
# Control how the cursor appears in the various vim modes. This only applies
# if $VI_MODE_SET_CURSOR=true.
#
# See https://vt100.net/docs/vt510-rm/DECSCUSR for cursor styles
typeset
-g
VI_MODE_CURSOR_NORMAL
=
2
typeset
-g
VI_MODE_CURSOR_VISUAL
=
6
typeset
-g
VI_MODE_CURSOR_INSERT
=
6
typeset
-g
VI_MODE_CURSOR_OPPEND
=
0
typeset
-g
VI_KEYMAP
=
main
function
_vi-mode-set-cursor-shape-for-keymap
()
{
...
...
@@ -22,13 +31,13 @@ function _vi-mode-set-cursor-shape-for-keymap() {
# https://vt100.net/docs/vt510-rm/DECSCUSR
local
_shape
=
0
case
"
${
1
:-${
VI_KEYMAP
:-
main
}}
"
in
main
)
_shape
=
6
;;
# vi insert: line
viins
)
_shape
=
6
;;
# vi insert: line
isearch
)
_shape
=
6
;;
# inc search: line
command
)
_shape
=
6
;;
# read a command name
vicmd
)
_shape
=
2
;;
# vi cmd: block
visual
)
_shape
=
2
;;
# vi visual mode: block
viopp
)
_shape
=
0
;;
# vi operation pending: blinking block
main
)
_shape
=
$VI_MODE_CURSOR_INSERT
;;
# vi insert: line
viins
)
_shape
=
$VI_MODE_CURSOR_INSERT
;;
# vi insert: line
isearch
)
_shape
=
$VI_MODE_CURSOR_INSERT
;;
# inc search: line
command
)
_shape
=
$VI_MODE_CURSOR_INSERT
;;
# read a command name
vicmd
)
_shape
=
$VI_MODE_CURSOR_NORMAL
;;
# vi cmd: block
visual
)
_shape
=
$VI_MODE_CURSOR_VISUAL
;;
# vi visual mode: block
viopp
)
_shape
=
$VI_MODE_CURSOR_OPPEND
;;
# vi operation pending: blinking block
*
)
_shape
=
0
;;
esac
printf
$'
\e
[%d q'
"
${
_shape
}
"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment