How can I get a block cursor in Vim in the Cygwin terminal?
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.
Related videos on Youtube
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, 2022Comments
-
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 over 10 yearsTo complete, this kind of options are the same as any other windows terminal window, which cygwin is.
-
Kazark over 10 yearsPro: 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 theI
cursor in that mode. +1 -
zzapper about 10 yearsthis worked for me when using mintty to ssh to a linux server
-
rld. almost 10 yearsThank you so much. Gotta love a clean solution that works in 2 most annoying cases :)
-
David Alpert over 8 yearsthe 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 almost 8 yearsmy vim is plain text - click? bar? what bar?
-
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 over 7 yearsThis 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 over 7 yearsNice. 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 over 7 yearsIt'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 almost 7 yearsAlmost perfect... but when leaving insert mode, it returns to a line cursor until you move the cursor in some direction.
-
Bangash almost 7 yearsWorked for me in the version of Vim installed automatically with Cmder. Thank You!
-
Kevin Tighe over 6 yearsWorked for me in git bash on windows (mysys2) as well!
-
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 over 4 yearsI 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 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 almost 3 yearsyou 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 over 2 yearsI'm running ubuntu on WSL2. This worked for me as well. Thanks!