1

If I switch to copy mode in tmux (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 tmux to properly highlight all selected characters, including the one under the cursor just like in vim. How can I do that?

I tested it also without vi mode and with an empty .tmux.config file, and the same thing happens. So I don't think it has to do with my configuration.

Interestingly, the same exact behavior also happens in zsh when selecting text in zsh Vi mode.

2
  • If that's a block cursor, it's basically reverse-video, and since the selection would be in reverse-video, the application has to do some tweaks to keep the cursor visible, e.g., using color. But that's terminal-dependent. Jul 12, 2022 at 0:04
  • I just realized that the issue doesn't happen on my macbook (with my same config). So I suppose it is terminal dependent. Not sure what's going on tho
    – WalksB
    Jul 12, 2022 at 21:56

1 Answer 1

2

From tmux(1) one might find

Ss, Se  Set or reset the cursor style ... `printf '\033[4 q'`

However this only applies in normal mode; the default cursor returns in copy mode. At a guess vim probably issues a tput civis, tput cnorm pair around the highlight to render the cursor temporarily invisible. The copy-mode-match-style and similar do not appear to affect the cursor in limited testing, though tmux version 3.3 added the following:

* Add cursor-style and cursor-colour options to set the default
  cursor style and colour.

This would need to be patched into older versions, or older versions upgraded to 3.3 or higher.

tmux has various hooks though after-copy-mode is probably not suitable as that mode must still show the cursor but hide it whenever a highlight begins (and then show the cursor again should the user cancel a particular highlight). One not too terrible option might be to change the copy-mode cursor to be an underline, which leaves it mostly visible while mostly not getting in the way of the highlight:

set-hook -g after-copy-mode 'set -p cursor-style underline'

cursor-colour may also be productive to fiddle around with to make it match the copy-mode-current-match-style value, though I have not experimented with that as I disable colors.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .