Vim selection underlined rather than reversed

95 views
Skip to first unread message

Jeenu

unread,
Apr 15, 2019, 11:24:31 AM4/15/19
to vim_use
Sometimes, after I attach to a tmux session, visual selection in an already-running vim instance is shown as underlined instead of reversed. See the attached files for the difference; both are from the same host - one from new, and the other from existing session. The only way out I've found is to quit and launch vim again. Does any one know why this happens and/or how to fix it?

This is the same problem as someone had posted a while ago: https://superuser.com/questions/1186500/vim-visually-selected-text-sometimes-appears-as-underlined-not-reversed

Thanks,
Jeenu

Capture.PNG
working.PNG

Tony Mechelynck

unread,
Apr 15, 2019, 2:18:03 PM4/15/19
to vim...@googlegroups.com
I don't know why it happens but I know how to find out: next time the
problem happens, and after making sure Vim is in Normal mode (this
will usually mean hitting <Esc>, which will clear the Visual
highlighting) type

:verbose hi Visual

followed by <Enter>. Vim will answer by telling you not only exactly
what the Visual highlight is now set to, but also, which line of which
script (if any) last changed it. The script name and line can only be
missing if that highlight is either at its default, or was last set
manually.

Another possibly relevant setting is the 'background' setting, which
may be "dark" or "light" (without the quotes) and defines whether Vim
thinks that your current default background is a dark one or a bright
one respectively.

:verbose set bg

will tell you the current value and which script (if any) last set it.
Here it is more likely that no script will be mentioned, meaning the
value is still the default value (which, in Console Vim, can be either
"light" or "dark" depending on what Vim believes that you were using
immediately before startup; in gvim, whose Normal highlight is usually
black on white unless you are using a colorscheme, the default is
usually "light").

Best regards,
Tony.

Grant Taylor

unread,
Apr 15, 2019, 2:46:23 PM4/15/19
to vim...@googlegroups.com
On 4/15/19 9:24 AM, Jeenu wrote:
> Sometimes, after I attach to a tmux session, visual selection in
> an already-running vim instance is shown as underlined instead of
> reversed. See the attached files for the difference; both are from the
> same host - one from new, and the other from existing session. The only
> way out I've found is to quit and launch vim again. Does any one know
> why this happens and/or how to fix it?

This sounds to me like screen is loosing state and not (re)displaying
things properly after some condition.

I would bet another order of magnitude that this is the case if you
visually select something so it's highlighted, change screen (disconnect
/ switch screens), change screen back (reconnect / switch back), and
what was highlighted is now underlined.
This seems to have the same symptoms to me.

You can probably test vim, if not eliminate it from the scenario, by
playing with ANSI control codes at a command line and see if the
symptoms are the same as vim when changing screen (see above).



--
Grant. . . .
unix || die

Jeenu

unread,
Apr 15, 2019, 3:00:32 PM4/15/19
to vim_use
On Monday, April 15, 2019 at 7:18:03 PM UTC+1, Tony Mechelynck wrote:

> On Mon, Apr 15, 2019 at 5:24 PM Jeenu wrote:
> >
> > Sometimes, after I attach to a tmux session, visual selection in an already-running vim instance is shown as underlined instead of reversed. See the attached files for the difference; both are from the same host - one from new, and the other from existing session. The only way out I've found is to quit and launch vim again. Does any one know why this happens and/or how to fix it?
> >
> > This is the same problem as someone had posted a while ago: https://superuser.com/questions/1186500/vim-visually-selected-text-sometimes-appears-as-underlined-not-reversed
> >
> > Thanks,
> > Jeenu
>
> I don't know why it happens but I know how to find out: next time the
> problem happens, and after making sure Vim is in Normal mode (this
> will usually mean hitting <Esc>, which will clear the Visual
> highlighting) type
>
> :verbose hi Visual

I've attached screen shots capture of running the command two sessions. The output of the hi command shows reversed mode in both sessions.

Also, both sessions say background is dark.

Not sure what to make of these.

Jeenu

visual_working.png
visual.png

Christian Brabandt

unread,
Apr 15, 2019, 3:15:19 PM4/15/19
to vim_use
Please show the text output.

Another thing that is likely to be the cause is, Vim is using the
VisualNOS highlighting group. This is used, when Vim cannot connect to
the X Server. You mentioned using tmux and re-attaching sessions, so my
guess is, the re-attachment made Vim not correctly reset the X connect.

So the different highlighting is a way to let you know of it.

There was an issue about Vim not correctly resetting up the X
connection, (I believe #3649) and a fix seems to have been included by
8.1.0615.

Best,
Christian
--
Mir willst du zum Gotte machen
Solch ein Jammerbild am Holze!
-- Johann Wolfgang von Goethe

Tony Mechelynck

unread,
Apr 15, 2019, 3:25:39 PM4/15/19
to vim...@googlegroups.com
The right-hand screenshot (with underlining) shows that the highlight
was set by the "desert" colorscheme.

:colors default

will clear that.

Best regards,
Tony.

Jeenu

unread,
Apr 15, 2019, 3:47:46 PM4/15/19
to vim_use
On Monday, April 15, 2019 at 8:15:19 PM UTC+1, Christian Brabandt wrote:
> On Mo, 15 Apr 2019, Jeenu wrote:
>
> > On Monday, April 15, 2019 at 7:18:03 PM UTC+1, Tony Mechelynck wrote:
> > > On Mon, Apr 15, 2019 at 5:24 PM Jeenu wrote:
> > > >
> > > > Sometimes, after I attach to a tmux session, visual selection in an already-running vim instance is shown as underlined instead of reversed. See the attached files for the difference; both are from the same host - one from new, and the other from existing session. The only way out I've found is to quit and launch vim again. Does any one know why this happens and/or how to fix it?
> > > >
> > > > This is the same problem as someone had posted a while ago: https://superuser.com/questions/1186500/vim-visually-selected-text-sometimes-appears-as-underlined-not-reversed
> > > >
> > > > Thanks,
> > > > Jeenu
> > >
> > > I don't know why it happens but I know how to find out: next time the
> > > problem happens, and after making sure Vim is in Normal mode (this
> > > will usually mean hitting <Esc>, which will clear the Visual
> > > highlighting) type
> > >
> > > :verbose hi Visual
> >
> > I've attached screen shots capture of running the command two sessions. The output of the hi command shows reversed mode in both sessions.
> >
> > Also, both sessions say background is dark.
> >
> > Not sure what to make of these.
>
> Please show the text output.

:verbose hi Visual
Visual xxx term=reverse cterm=reverse ctermbg=242 guifg=khaki guibg=olivedrab
Last set from /usr/share/vim/vim74/colors/desert.vim
Press ENTER or type command to continue

> Another thing that is likely to be the cause is, Vim is using the
> VisualNOS highlighting group. This is used, when Vim cannot connect to
> the X Server. You mentioned using tmux and re-attaching sessions, so my
> guess is, the re-attachment made Vim not correctly reset the X connect.
>
> So the different highlighting is a way to let you know of it.
>
> There was an issue about Vim not correctly resetting up the X
> connection, (I believe #3649) and a fix seems to have been included by
> 8.1.0615.

The Cygwin server I'm running on my Windows host (vim runs on a remote Linux host) did restart, so could be that issue.

Jeenu

Jeenu

unread,
Apr 15, 2019, 3:48:45 PM4/15/19
to vim_use
On Monday, April 15, 2019 at 8:25:39 PM UTC+1, Tony Mechelynck wrote:

Switching color scheme didn't have any effect, if that's what you were suggesting.

Jeenu

unread,
Apr 29, 2019, 5:12:35 AM4/29/19
to vim_use
On Monday, April 15, 2019 at 8:15:19 PM UTC+1, Christian Brabandt wrote:
> There was an issue about Vim not correctly resetting up the X
> connection, (I believe #3649) and a fix seems to have been included by
> 8.1.0615.

From the observations I've made so far, it does seem like X server disconnection/restart is causing this problem.

My reading is that https://github.com/vim/vim/pull/844 is the PR that has a fix, but hasn't been merged yet.

I'm currently using a prebuilt 8.1.1139, which supposedly contains the "fix" mentioned in https://github.com/vim/vim/issues/3649#issuecomment-449705992, but I observe the same issue as before.

So I suppose I wait until #844 is merged.

--
Jeenu

Christian Brabandt

unread,
Apr 29, 2019, 5:27:05 AM4/29/19
to vim_use
Try increasing the limits mentioned here:
https://github.com/vim/vim/issues/3649#issuecomment-445868123

You need to recompile.


Best,
Christian
--
Jedem Narren gefällt seine Kappe.
-- Sprichwort

Jeenu

unread,
Jun 3, 2019, 4:04:47 AM6/3/19
to vim_use

I'm happy to report that, as of 8.1.1413, Vim has an :xrestore command with which I could get the display back to normal after an X window restart!

--
Jeenu

Reply all
Reply to author
Forward
0 new messages