6

Vim's documentation lists t_vi as "cursor invisible" and t_ve as "cursor visible", but provides no hints on usage. Naively, I would have guessed that Vim would send the t_vi sequence when you somehow indicated cursor should be hidden (e.g., using something analogous to guicursor, or even the 'Cursor' syntax group), but the only way I've been able to hide the cursor in a terminal is to make the "cursor visible" option empty: e.g.,

set t_ve=

In other words, telling Vim there's no way to make the cursor visible causes Vim immediately to use the t_vi option value to make it invisible. The seems a little odd and unintuitive to me. I couldn't find any information in Vim's docs on this. Is it well-defined behavior? Can anyone give a better explanation of what's happening here?

1 Answer 1

3

This is a bug. vim uses the cursor invisible/visible escapes to reduce cursor-flicker while updating the screen.

Reading term.c, vim checks if t_VE is empty in ttest if pairs is true. But pairs is only true when first reading the terminal description. After that (for example, if you set the variable directly), it calls ttest with pairs false.

So vim does not notice when t_VE and t_VI are no longer consistent, and goes ahead to hide the cursor without noticing that it cannot show the cursor again. If you look at the source code for cursor_on and cursor_off, you may notice that the respective variables are not checked for consistency.

There's a comment before the check noting why it is done, from 2019. But the rest of the logic dates from 2004 (when the file was copied from CVS). Actually it's older than that, but in importing from CVS a lot of history was discarded. CVS itself came late in the 1990s, so before that are only a dozen or so tarballs. In a quick check, the option to set those values came in between 4.0 and 5.0 (1996 to 1998).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.