Changing cursor style based on mode in both zsh and vim
Clash Royale CLAN TAG#URR8PPP
up vote
3
down vote
favorite
I use vi-mode in oh-my-zsh with the af-magic theme.
I want the cursor style to indicate whether I am in normal mode (block) or insert mode (beam), both in zsh
and in vim
.
This is what I have so far:
In my ~/.zshrc
:
# vim mode config
# ---------------
# Activate vim mode.
bindkey -v
# Remove mode switching delay.
KEYTIMEOUT=5
# Change cursor shape for different vi modes.
function zle-keymap-select
[[ $KEYMAP == viins ]]
zle -N zle-keymap-select
# Use beam shape cursor on startup.
echo -ne 'e[5 q'
# Use beam shape cursor for each new prompt.
preexec()
echo -ne 'e[5 q'
As found here.
In vim
, I use Vundle and terminus.
With these configurations, both zsh
and vim
work as they should when considered independently.
However, when I enter vim
from zsh
in insert mode, vim
starts in normal mode (as it should) but still shows the beam shape cursor.
Similarly, when I exit vim
, I get back to zsh
in insert mode, but the cursor is still in block shape (since the last mode in vim
was normal).
When after this, I switch modes for the first time (in both zsh
and vim
), the cursor behaves the way it should again.
How can I make them display the correct cursor after entering and exiting vim
as well?
I tried putting
autocmd VimEnter * stopinsert
autocmd VimLeave * startinsert
in my ~.vimrc
, but this does not affect the cursor.
vim zsh oh-my-zsh caret-cursor
add a comment |Â
up vote
3
down vote
favorite
I use vi-mode in oh-my-zsh with the af-magic theme.
I want the cursor style to indicate whether I am in normal mode (block) or insert mode (beam), both in zsh
and in vim
.
This is what I have so far:
In my ~/.zshrc
:
# vim mode config
# ---------------
# Activate vim mode.
bindkey -v
# Remove mode switching delay.
KEYTIMEOUT=5
# Change cursor shape for different vi modes.
function zle-keymap-select
[[ $KEYMAP == viins ]]
zle -N zle-keymap-select
# Use beam shape cursor on startup.
echo -ne 'e[5 q'
# Use beam shape cursor for each new prompt.
preexec()
echo -ne 'e[5 q'
As found here.
In vim
, I use Vundle and terminus.
With these configurations, both zsh
and vim
work as they should when considered independently.
However, when I enter vim
from zsh
in insert mode, vim
starts in normal mode (as it should) but still shows the beam shape cursor.
Similarly, when I exit vim
, I get back to zsh
in insert mode, but the cursor is still in block shape (since the last mode in vim
was normal).
When after this, I switch modes for the first time (in both zsh
and vim
), the cursor behaves the way it should again.
How can I make them display the correct cursor after entering and exiting vim
as well?
I tried putting
autocmd VimEnter * stopinsert
autocmd VimLeave * startinsert
in my ~.vimrc
, but this does not affect the cursor.
vim zsh oh-my-zsh caret-cursor
add a comment |Â
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I use vi-mode in oh-my-zsh with the af-magic theme.
I want the cursor style to indicate whether I am in normal mode (block) or insert mode (beam), both in zsh
and in vim
.
This is what I have so far:
In my ~/.zshrc
:
# vim mode config
# ---------------
# Activate vim mode.
bindkey -v
# Remove mode switching delay.
KEYTIMEOUT=5
# Change cursor shape for different vi modes.
function zle-keymap-select
[[ $KEYMAP == viins ]]
zle -N zle-keymap-select
# Use beam shape cursor on startup.
echo -ne 'e[5 q'
# Use beam shape cursor for each new prompt.
preexec()
echo -ne 'e[5 q'
As found here.
In vim
, I use Vundle and terminus.
With these configurations, both zsh
and vim
work as they should when considered independently.
However, when I enter vim
from zsh
in insert mode, vim
starts in normal mode (as it should) but still shows the beam shape cursor.
Similarly, when I exit vim
, I get back to zsh
in insert mode, but the cursor is still in block shape (since the last mode in vim
was normal).
When after this, I switch modes for the first time (in both zsh
and vim
), the cursor behaves the way it should again.
How can I make them display the correct cursor after entering and exiting vim
as well?
I tried putting
autocmd VimEnter * stopinsert
autocmd VimLeave * startinsert
in my ~.vimrc
, but this does not affect the cursor.
vim zsh oh-my-zsh caret-cursor
I use vi-mode in oh-my-zsh with the af-magic theme.
I want the cursor style to indicate whether I am in normal mode (block) or insert mode (beam), both in zsh
and in vim
.
This is what I have so far:
In my ~/.zshrc
:
# vim mode config
# ---------------
# Activate vim mode.
bindkey -v
# Remove mode switching delay.
KEYTIMEOUT=5
# Change cursor shape for different vi modes.
function zle-keymap-select
[[ $KEYMAP == viins ]]
zle -N zle-keymap-select
# Use beam shape cursor on startup.
echo -ne 'e[5 q'
# Use beam shape cursor for each new prompt.
preexec()
echo -ne 'e[5 q'
As found here.
In vim
, I use Vundle and terminus.
With these configurations, both zsh
and vim
work as they should when considered independently.
However, when I enter vim
from zsh
in insert mode, vim
starts in normal mode (as it should) but still shows the beam shape cursor.
Similarly, when I exit vim
, I get back to zsh
in insert mode, but the cursor is still in block shape (since the last mode in vim
was normal).
When after this, I switch modes for the first time (in both zsh
and vim
), the cursor behaves the way it should again.
How can I make them display the correct cursor after entering and exiting vim
as well?
I tried putting
autocmd VimEnter * stopinsert
autocmd VimLeave * startinsert
in my ~.vimrc
, but this does not affect the cursor.
vim zsh oh-my-zsh caret-cursor
edited Mar 24 at 20:32
ñÃÂsýù÷
14.8k82462
14.8k82462
asked Mar 24 at 15:15
maddingl
386
386
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
I have found a solution:
I put this in my ~/.vimrc
:
autocmd VimEnter * silent exec "! echo -ne 'e[1 q'"
autocmd VimLeave * silent exec "! echo -ne 'e[5 q'"
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
I have found a solution:
I put this in my ~/.vimrc
:
autocmd VimEnter * silent exec "! echo -ne 'e[1 q'"
autocmd VimLeave * silent exec "! echo -ne 'e[5 q'"
add a comment |Â
up vote
1
down vote
accepted
I have found a solution:
I put this in my ~/.vimrc
:
autocmd VimEnter * silent exec "! echo -ne 'e[1 q'"
autocmd VimLeave * silent exec "! echo -ne 'e[5 q'"
add a comment |Â
up vote
1
down vote
accepted
up vote
1
down vote
accepted
I have found a solution:
I put this in my ~/.vimrc
:
autocmd VimEnter * silent exec "! echo -ne 'e[1 q'"
autocmd VimLeave * silent exec "! echo -ne 'e[5 q'"
I have found a solution:
I put this in my ~/.vimrc
:
autocmd VimEnter * silent exec "! echo -ne 'e[1 q'"
autocmd VimLeave * silent exec "! echo -ne 'e[5 q'"
answered Mar 24 at 20:28
maddingl
386
386
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f433273%2fchanging-cursor-style-based-on-mode-in-both-zsh-and-vim%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password