Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux Subsystem for Windows - Vim - Mouse Cursor Doesn't Change Change Width #937

Open
raffylopez opened this issue Nov 2, 2016 · 10 comments

Comments

@raffylopez
Copy link

I'm using ConEmu for both vim.exe and vim on bash. In vim.exe, going from Normal mode to Insert mode makes the cursor switch from fat to thin, and vice versa, but the same doesn't apply for vim on bash. I am aware that the text cursor width can be adjusted in the settings, but I haven't seen any config that influences automatic text width-toggling within vim/bash.

@ChasonDeshotel
Copy link

Looks like Microsoft fixed this March 20th. Limited to Insider builds for now. Source: microsoft/terminal#68

So with an Insider build of Windows, this will work (added to .vimrc):

let &t_SI.="\e[5 q"
let &t_SR.="\e[4 q"
let &t_EI.="\e[1 q"

I'm not sure if they fixed the root issue of not passing ReadConsole state or if they're just fixed the escape sequences. If it's the latter, explicitly tell vim what you want the cursor set to be you're all set

@kariem-ali
Copy link

The related windows issue microsoft/terminal#68 has been fixed in Windows 10 version 1809 (Build 17763.194). Running bash.exe directly (not through ConEmu), the cursor changes in insert mode:

Normal Mode
vim-cursor-normal

Insert Mode
vim-cursor-insert

@Maximus5 Not sure if this fixes the root issue you mentioned before that prevents ConEmu from accessing the Real Console state. Any plans to look into this in light of this new fix?

@kariem-ali
Copy link

kariem-ali commented Dec 18, 2018

I have created a workaround for this. Sticking this into your .vimrc will get your cursor to switch between block and beam for normal mode and insert mode respectively:

if has("autocmd")
   let conEmuMacro = "!/mnt/c/utils/ConEmu/ConEmu/ConEmuC64.exe -guimacro setoption check"
   let beamCursor = conEmuMacro . " 2531 " . "1 >/dev/null 2>&1 &"
   let blockCursor = conEmuMacro . " 2532 " . "1 >/dev/null 2>&1 &"

   au VimLeave * silent execute beamCursor | redraw!
   au VimEnter * silent execute blockCursor | redraw!

   au InsertEnter * silent execute beamCursor | redraw!
   au InsertLeave * silent execute blockCursor | redraw!
endif

You need to change this line let conEmuMacro = "!/mnt/c/utils/ConEmu/ConEmu/ConEmuC64.exe .... to point to your ConEmuC executable.

This basically utilizes a combination of Vim auto-commands and ConEmu GUI macros to force ConEmu to change the cursor shape when Vim enters or leaves insert mode. Forcing Vim to redraw the screen (the redraw! above) is necessary after the cursor change, otherwise you will get screen artifacts.

Needless to say that this is a hack and forcing Vim to clean and redraw the screen each time you enter and leave insert mode like that causes a delay in your workflow.

@offero
Copy link

offero commented Jan 6, 2019

I just ran into this also. It's pretty important for me and will deter me from working in cmder as I am using vim all the time.

@ragvri
Copy link

ragvri commented Dec 21, 2019

@offero Did you get this to work?

@ChasonDeshotel
Copy link

ChasonDeshotel commented Dec 21, 2019

@ragvri @offero I tried for quite a while, even as recently as a couple weeks ago. I was never able to get Vim cursors to work correctly in ConEmu. I switched to Terminus which I really love. Not near as many options but I honestly haven't needed any beyond what's provided. Cursor worked exactly as it should, no hacks or workarounds. That cursor thing was a total workflow killer

@ragvri
Copy link

ragvri commented Dec 22, 2019

@ChasonDeshotel Thanks for this. Works perfectly, although it is a little resource heavy.

Did you also try alacritty? It seems to be resource light.

Update: It does not seem to work for me without adding some lines in my vimrc. I am using wsl and terminus.

@parml
Copy link

parml commented Mar 6, 2020

An update. This still doesn't work.

Environment:
Windows 10.0.18363.657
ConEmu 19.10.12.0

Using vim on bash in WSL.
@kariem-ali's solution does not work for me (added suggested code with adapted path the the ConEmu64.exe to ~/.vimrc).

@ChasonDeshotel
Copy link

@ragvri way late here but yes, I did try Alacritty and was unable to get it to work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants
@ChasonDeshotel @Maximus5 @kariem-ali @parml @offero @raffylopez @ragvri and others