44

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?

72

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"
  • 2
    this worked for me when using mintty to ssh to a linux server – zzapper Apr 15 '14 at 12:41
  • 2
    Thank you so much. Gotta love a clean solution that works in 2 most annoying cases :) – rld. Jun 8 '14 at 5:58
  • 2
    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? ;) – George Marian Aug 17 '16 at 15:44
  • 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 '17 at 15:55
  • 1
    Worked for me in the version of Vim installed automatically with Cmder. Thank You! – Bangash Jun 16 '17 at 14:03
30

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

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

  • To complete, this kind of options are the same as any other windows terminal window, which cygwin is. – mveroone Aug 22 '13 at 9:35
  • 6
    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 '13 at 13:21
  • 5
    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 – David Alpert Jan 15 '16 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. – Jared Jul 14 '16 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. – George Marian Aug 17 '16 at 15:35
2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.