Cursor disappears in vim when switching windows between vertical and horizontal split

StackOverflow https://stackoverflow.com/questions/1025762

  •  06-07-2019
  •  | 
  •  

Question

I've been switching some windows in VIM from vertical to horizontal splits and back using:

CTRL-W + K
CTRL-W + L
CTRL-W + J
CTRL-W + H

After doing this a few times the cursor disappeared. I can still type, and the status bar at the bottom still shows me my location, but there's no blinking cursor. Any ideas regarding:

  1. Why does this happen?
  2. How do I get the cursor back?

I'm using vim 7.2 on Linux

Was it helpful?

Solution

I have the same problem and I have used couple of work-arounds that work for me:

  1. Maximize gvim window and then click on the maximize button again to bring it to original size. This brings back the cursor.
  2. Run some shell command e.g., !echo > /dev/null - this seems to bring back the cursor as well.

I am experimenting whether doing the following (remove the left side scroll bar completely) fixes this problem completely or not - this seems to work in limited experiments but the jury is still out on this :)

set guioptions-=L

set guioptions=-l

Osho

OTHER TIPS

:colorscheme <you colorscheme>

Gets cursor back for me.

It's logged as a bug against Ubuntu (although it also occurs in Fedora) https://bugs.launchpad.net/ubuntu/+source/vim/+bug/616858

From the bug report, two other workarounds:

  • disabling the mousehide option (:set nohousehide) stops the bug from appearing
  • double-clicking to highlight a word causes the cursor to appear again.

Hope this helps.

I've noticed this a few times in gvim on Ubuntu. Haven't got an idea of what causes it but sourcing vimrc again seems to solve it.

I've noticed that when you open gvim without any files and then use :e and :vsplit you never lose the cursor.

Look into your ~/.gvimrc file, comment everything out and launch gvim again. Look it the problem is still there. Do some binary search to see exactly what's causing the problem.

In my case it was this line, which I removed:

set gcr=n:blinko

This should prevent cursor from blinking. I can live without it. Maybe I did an update and something changed in regards to this configuration.

Try reloading the color scheme, worked for me...

I did the following

:syntax reset
:colorscheme mycolortheme

i've noticed that the best way to recover cursor when playing with windows(vim windows) is to reload the .vimrc file.

in order to do this easily, i've added a shortcut in order to source VIMRC. After sourcing vimrc my cursor reappear for insert mode.

so far i have not found out why the cursor is disappearing.

" - | reloading vimrc, sourcing it 
nnoremap <leader>sv :source $MYVIMRC<CR>

my leader is ",,"

so when i type : ,,sv my cursor reappear for insert mode.

I had the same problem using vimx from gnome-terminal (not gvim, as some other commentators do).

I noticed that the cursor disappeared only in command and insert mode and was present in visual mode. I tried all advice above, but that didn't help. Here is a good wiki on configuring the cursor in vim, but that didn't help either.

I tried vimx, vim, vi with the same file, and found that none of them showed the cursor. Then I had noticed that gnome-terminal neither showed the cursor.

Here are some suggestions on how to make gnome-terminal show cursor. I simply used another tab and that worked.

I tried sourcing .vimrc and that didn't help.

I noticed that the blinking cursor is available if I launch (g)vim with a -O option and my files, rather than load a single file then do a split and load via :vspl filename.

You can try CTRL+L to redraw the screen.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top