How can I get a block cursor in Vim in the Cygwin terminal?

51

15

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?

Kazark

Posted 2013-08-20T17:45:10.297

Reputation: 2 871

Answers

78

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"

Kazark

Posted 2013-08-20T17:45:10.297

Reputation: 2 871

3Nice. 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? ;) – George Marian – 2016-08-17T15:44:07.083

1Almost perfect... but when leaving insert mode, it returns to a line cursor until you move the cursor in some direction. – Joe Coder – 2017-06-12T15:55:26.290

1Worked for me in the version of Vim installed automatically with Cmder. Thank You! – Bangash – 2017-06-16T14:03:06.877

Worked for me in git bash on windows (mysys2) as well! – Kevin Tighe – 2017-10-18T13:18:59.877

3this worked for me when using mintty to ssh to a linux server – zzapper – 2014-04-15T12:41:31.503

2Thank you so much. Gotta love a clean solution that works in 2 most annoying cases :) – rld. – 2014-06-08T05:58:47.827

33

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

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

Johnny Hoang

Posted 2013-08-20T17:45:10.297

Reputation: 456

5the 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 – David Alpert – 2016-01-15T16:09:02.520

my vim is plain text - click? bar? what bar? – Ed Randall – 2016-06-10T14:14:06.710

1@EdRandall this is a question about the Cygwin terminal AND vim. This answer pertains to the Cygwin side of the question. – shmup – 2016-07-14T19:57:08.040

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.

– George Marian – 2016-08-17T15:35:38.207

It's been noted that this affects the entire shell session. For me, Vim seemed to be inheriting that shell session cursor format. Modifying Vim settings alone didn't help. Changing the option as suggested in this post did. – Mike – 2017-01-27T13:33:30.907

@DavidAlpert The question is about vim in Cygwin. This answers the question. It may not be ideal because it affects other programs, BUT, as a Cygwin user, there is a good chance that that is what you're looking for when you find this page. (I was.) I agree this kind of answer would be a bad answer if the platform was Linux, but in this case it may be what users are looking for. – felwithe – 2019-10-07T14:57:52.143

I don't think it changes the cursor type to vertical when we are in the insert mode. I am getting a block cursor all the time in cygwin now, even if I am in the insert mode in vim. – ragvri – 2019-12-21T04:07:01.130

To complete, this kind of options are the same as any other windows terminal window, which cygwin is. – mveroone – 2013-08-22T09:35:36.743

6Pro: 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 – 2013-08-22T13:21:21.720

3

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

CursorType=block

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

qeatzy

Posted 2013-08-20T17:45:10.297

Reputation: 227

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.

Andreas Spindler

Posted 2013-08-20T17:45:10.297

Reputation: 199