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

Powershell : Cursor shape does not recover after exiting vim #5

Closed
PrashanthaTP opened this issue Aug 21, 2021 · 5 comments
Closed
Labels
bug Something isn't working

Comments

@PrashanthaTP
Copy link
Owner

PrashanthaTP commented Aug 21, 2021

Issue Description

After exiting vim cursor is in block state itself

image

Expected

image

More Info

@PrashanthaTP PrashanthaTP added the bug Something isn't working label Aug 21, 2021
PrashanthaTP added a commit that referenced this issue Aug 21, 2021
(Issue) cursor does not reset on exiting from vim
    - microsoft/terminal#4335

(Issue : #5)
PrashanthaTP added a commit that referenced this issue Aug 21, 2021
(Issue) cursor does not reset on exiting from vim
    - microsoft/terminal#4335
@PrashanthaTP
Copy link
Owner Author

PrashanthaTP commented Aug 29, 2021

helpful links :

tried :
(doesn't work ❌)

" https//vim.fandom.com/wiki/Configuring_the_cursor
" 1 or 0 -> blinking block
" 2 solid block
" 3 -> blinking underscore
" 4 solid underscore
" Recent versions of xterm (282 or above) also support
" 5 -> blinking vertical bar
" 6 -> solid vertical bar

autocmd VimLeave * silent !echo  -ne "\e[6 q"
autocmd VimLeave * silent !printf  "\e[6 q"

works ✔

autocmd VimLeave * set guicursor=a:ver25

see :help guicursor

PrashanthaTP added a commit that referenced this issue Aug 29, 2021
why:
to distinguish between command and normal modes of vi mode in
powershell

how:
using VimLeave event and guicursor option

misc:
see :help guicursor

links:
- neovim/neovim#4867
- microsoft/terminal#4335

tags:
cursor,cursor-shape

fixes #5
PrashanthaTP added a commit that referenced this issue Aug 29, 2021
why:
to distinguish between command and normal modes of vi mode in
powershell

how:
using VimLeave event and guicursor option

misc:
see :help guicursor

links:
- neovim/neovim#4867
- microsoft/terminal#4335

tags:
cursor,cursor-shape

fixes #5
@younger-1
Copy link

In powershell, autocmd VimLeave * set guicursor=a:ver25 works only for neovim but not vim. Is there a way to restore the cursor to default in vim?

@PrashanthaTP
Copy link
Owner Author

PrashanthaTP commented Feb 15, 2022

Hmmm,
did you try one of these autocommands

" https//vim.fandom.com/wiki/Configuring_the_cursor 
" 1 or 0 -> blinking block
 " 2 solid block
 " 3 -> blinking underscore 
" 4 solid underscore " Recent versions of xterm (282 or above) also support 
" 5 -> blinking vertical bar 
" 6 -> solid vertical bar 

autocmd VimLeave * silent !echo -ne "\e[6 q"

autocmd VimLeave * silent !printf "\e[6 q"

@younger-1
Copy link

🥲 these autocmds only works in WSL(ubuntu/arch..), not in powershell

@Xiaorui-Huang
Copy link

@younger-1
Since I wanted to use the default vintage cursor ( ▃ ), requiring "\e[0 q", so none of the above worked for me, but I have found a workaround by resetting the cursor whenever the prompt is rendered

if you use the default prompt, put this in your powershell profile

function prompt{
    ...
    Write-Host -NoNewLine "`e[0 q"
}

If you use oh-my-posh

function Set-PromptContext{
   ...
   Write-Host -NoNewLine "`e[0 q"
}
New-Alias -Name 'Set-PoshContext' -Value 'Set-PromptContext' -Scope Global -Force

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants