59

I am used to having a block cursor in normal mode in Vim. This makes sense with the Vim paradigm; when you press x, it is clear which character will be deleted.

I've installed Cygwin on a Windows computer, but when I use Vim in its terminal, I get the I cursor, even in normal mode. How can I make the cursor be a block instead?

5 Answers 5

91

This question on the Cygwin mailing list answers the question by setting some arcane variables to the appropriate escape sequences. Add this to your .vimrc:

let &t_ti.="\e[1 q"
let &t_SI.="\e[5 q"
let &t_EI.="\e[1 q"
let &t_te.="\e[0 q"
10
  • 3
    this worked for me when using mintty to ssh to a linux server
    – zzapper
    Apr 15, 2014 at 12:41
  • 2
    Thank you so much. Gotta love a clean solution that works in 2 most annoying cases :)
    – rld.
    Jun 8, 2014 at 5:58
  • 4
    Nice. Unfortunately, in ConEmu this affects the cursor for the entire session. That said, it works as expected in vim. It also works fine in cygwin's terminal emulator. But, who uses that? ;) Aug 17, 2016 at 15:44
  • 2
    Almost perfect... but when leaving insert mode, it returns to a line cursor until you move the cursor in some direction.
    – Joe Coder
    Jun 12, 2017 at 15:55
  • 1
    Worked for me in the version of Vim installed automatically with Cmder. Thank You!
    – Bangash
    Jun 16, 2017 at 14:03
38

There's a setting for that, in the cygwin terminal emulator:

Right-click on the window title bar > Options > Looks > Cursor > Cursor radio button

9
  • To complete, this kind of options are the same as any other windows terminal window, which cygwin is.
    – mveroone
    Aug 22, 2013 at 9:35
  • 8
    Pro: my .vimrc can be more compatible with my Linux or Windows .vimrc. Con: now I have the block cursor in insert mode, when I wanted the I cursor in that mode. +1
    – Kazark
    Aug 22, 2013 at 13:21
  • 6
    the question was asking about controlling the cursor in VIM but this answer affects the cursor for the entire shell session, both at the command prompt and in VIM Jan 15, 2016 at 16:09
  • 1
    @EdRandall this is a question about the Cygwin terminal AND vim. This answer pertains to the Cygwin side of the question.
    – shmup
    Jul 14, 2016 at 19:57
  • 1
    This doesn't answer the question completely. Vim uses 2 types of cursors. In normal, visual, or command mode it's a block. In insert mode, it's a vertical bar. These instructions are for a wholesale change in a specific terminal emulator (cygwin), though most should have something similar. So, it affects the cursor everywhere in the terminal, and, more importantly, it doesn't mimic vim's cursor functionality. Aug 17, 2016 at 15:35
4

Create a file ~/.minttyrc, add below line to it

CursorType=block

Then re-launch mintty, which is Cygwin's default terminal.

0

Or, you could create a batch file:

 %SYSTEMDRIVE%\cygwin\bin\mintty.exe ^
        -s 132,50 -o ScrollbackLines=10000 ^
        -o BackgroundColour=54,54,54 ^
        -o Transparency=High -o OpaqueWhenFocused=yes ^
        -o CursorColour=Green -o CursorType=block -o CursorBlinks=no ^
        -o Font=Consolas -o FontHeight=10 ^
        /bin/env CHERE_INVOKING=1 /bin/bash -l -i

And run it.

If you don't like the blinking cursor in the DOS command windows too use %COMSPEC% instead of /bin/env/... and be surprised.

0

People have raised the issue of @Kazark's answer setting the cursor for the entire shell session, to set it back to a line there are a couple of things you can do:

In .vimrc:

autocmd VimLeave * silent let &t_te.="\e[5 q"

Which should set in when you leave vim but it's not flawless (in particular when I'm running tmux on Windows and on a Linux machine I'm connected to), you can issue:

 printf '\033[5 q' 

at the command prompt.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .