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

33,349

Solution 1

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"

Solution 2

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

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

Solution 3

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

CursorType=block

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

Share:
33,349

Related videos on Youtube

Kazark
Author by

Kazark

profile for Kazark on Stack Exchange, a network of free, community-driven Q&A sites http://stackexchange.com/users/flair/443137.png The birthdate I entered is farcical, as I prefer not to identify myself in any way online, but the age is in the ballpark.

Updated on September 18, 2022

Comments

  • Kazark
    Kazark over 1 year

    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?

  • mveroone
    mveroone over 10 years
    To complete, this kind of options are the same as any other windows terminal window, which cygwin is.
  • Kazark
    Kazark over 10 years
    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
  • zzapper
    zzapper about 10 years
    this worked for me when using mintty to ssh to a linux server
  • rld.
    rld. almost 10 years
    Thank you so much. Gotta love a clean solution that works in 2 most annoying cases :)
  • David Alpert
    David Alpert over 8 years
    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
  • Ed Randall
    Ed Randall almost 8 years
    my vim is plain text - click? bar? what bar?
  • badteeth
    badteeth almost 8 years
    @EdRandall this is a question about the Cygwin terminal AND vim. This answer pertains to the Cygwin side of the question.
  • George Marian
    George Marian over 7 years
    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
    George Marian over 7 years
    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? ;)
  • Mike
    Mike over 7 years
    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.
  • Joe Coder
    Joe Coder almost 7 years
    Almost perfect... but when leaving insert mode, it returns to a line cursor until you move the cursor in some direction.
  • Bangash
    Bangash almost 7 years
    Worked for me in the version of Vim installed automatically with Cmder. Thank You!
  • Kevin Tighe
    Kevin Tighe over 6 years
    Worked for me in git bash on windows (mysys2) as well!
  • felwithe
    felwithe over 4 years
    @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.
  • humble
    humble over 4 years
    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.
  • user1934428
    user1934428 almost 3 years
    @GeorgeMarian : Just being curious: What is the cygwin terminal emulator? I am using mintty and ConEmu for Cygwin. Is there anything else available?
  • maninvan
    maninvan almost 3 years
    you can add the lines set ttimeout set ttimeoutlen=1 set listchars=tab:>-,trail:~,extends:>,precedes:<,space:. set ttyfast to make it switch quicker see stackoverflow.com/a/58042687/1766242
  • Prasanna
    Prasanna over 2 years
    I'm running ubuntu on WSL2. This worked for me as well. Thanks!