3

I've been using vim with multiple cursors for a few years now, but just today, while tinkering with my colorscheme, I found that the cursors weren't always showing up.
When they're visually selecting something, they use the color for the Visual highlighting group; however, if I'm not visually selecting, the multiple cursors are completely invisible, both with vim and gvim.
I have tried changing the Normal background color, but no use. They also don't seem to be using the settings for the Normal group, as they aren't visible over text with different background/foreground colors. What baffles me most is that this wasn't happening before.

Edit:

After some testing, it seems when I open vim to edit a file, the cursors are visible, but if I try to set the colorscheme, even to the one that is already set, they become (seemingly) permanently invisible.

Zoey Hewll
  • 4,788
  • 2
  • 20
  • 33

1 Answers1

3

Apparently, the plugin defines its own highlight groups. When you switch colorschemes, the customary :hi clear command at the top of the scheme removes all existing highlighting.

Ideally, the plugin would not define its own highlighting, but just link to an existing highlight group. At least the highlighting is customizable.

In order to support colorscheme changes that happen on the fly, the plugin would have to hook into the ColorScheme autocommand event, and reinitialize. (Not many plugins do that, though.)

As a workaround, you can do this on your own (e.g. in your ~/.vimrc):

:autocmd ColorScheme * runtime autoload/multiple_cursors.vim

(First select your (default) :colorscheme, then add the :autocmd. Any plugin customization would best be done before it, too. If that still doesn't lead to success, try putting just this into your .vimrc:

autocmd ColorScheme * hi multiple_cursors_cursor term=reverse cterm=reverse gui=reverse

This would be more efficient than re-sourcing the entire plugin script, but duplicates some information from the plugin.

Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324
  • Would that need to be in its own `augroup`? I remember having to do that for other autocommands – Zoey Hewll May 23 '17 at 14:30
  • Wow, weird. I tried inserting that line (minus the `:`) into my `~/.vimrc` and it prevents me from using the multiple-cursors at all, seeming to map `` and `` to `j` and `k` respectively – Zoey Hewll May 23 '17 at 14:36
  • You can surround this with `:augroup`, but it's only necessary to support reloading your `.vimrc`. – Ingo Karkat May 23 '17 at 14:43
  • 1
    The weird stuff may be due to the initialization order. First select your (default) `:colorscheme`, then add the `:autocmd`. Any plugin customization would best be done before it, too. If that still doesn't lead to success, try putting just this into your `.vimrc`: `autocmd ColorScheme * hi multiple_cursors_cursor term=reverse cterm=reverse gui=reverse` – Ingo Karkat May 23 '17 at 14:46
  • both those solutions worked; I'd accept them as an answer – Zoey Hewll May 23 '17 at 15:08
  • Ah, great! I've put both approaches into the answer itself. – Ingo Karkat May 23 '17 at 15:11