Nathan Fellman
Nathan Fellman

Reputation: 127558

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

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

Upvotes: 29

Views: 14816

Answers (11)

Robert Muil
Robert Muil

Reputation: 3085

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 nomousehide) stops the bug from appearing
  • double-clicking to highlight a word causes the cursor to appear again.

Hope this helps.

Upvotes: 4

Yaroslav Nikitenko
Yaroslav Nikitenko

Reputation: 1853

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.

Upvotes: 0

toshi
toshi

Reputation: 566

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.

Upvotes: 0

Fabrizio Regini
Fabrizio Regini

Reputation: 1500

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.

Upvotes: 1

mendezcode
mendezcode

Reputation: 983

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

I did the following

:syntax reset
:colorscheme mycolortheme

Upvotes: 0

graphite
graphite

Reputation: 2958

:colorscheme <you colorscheme>

Gets cursor back for me.

Upvotes: 6

Osho
Osho

Reputation: 356

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

Upvotes: 34

too much php
too much php

Reputation: 91058

You can try CTRL+L to redraw the screen.

Upvotes: -1

Qri
Qri

Reputation: 11

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

Upvotes: 1

the Tin Man
the Tin Man

Reputation: 160581

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.

Upvotes: -1

Ben
Ben

Reputation: 623

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.

Upvotes: 2

Related Questions