Search code examples
zshhighlightvi

Zsh vi copy mode selection - character under cursor is not highlighted


If I switch to copy mode in zsh (vi mode), and begin selecting text using v, the character that is directly under the cursor is never highlighted properly even though it is selected (i.e. if I copy the selection, that character shows up in the pasted text).

I want zsh to properly highlight all selected characters, including the one under the cursor just like in vim. How can I do that?

Here is the highlighting/color portion of my .zshrc file

autoload -U colors && colors    
PS1="%B%{$fg[red]%}[%{$fg[red]%}%n%{$fg[red]%}@%{$fg[red]%}%M %{$fg[red]%}%~%{$fg[red]%}]%{$reset_color%}$%b " 

Solution

  • You can set the region parameter of zle_highlight array by adding this line to your .zshrc configuration:

    zle_highlight=('region:bg=168,fg=251')

    Adjust the colors to your liking.

    Read more about character highlighting in zsh here.