How to change vim cursor shape in different modes

I use vim under iTerm2 on Mac or putty in windows. I want to see a different vim cursor shape in a different vim mode. I know that gvim and macvim have this feature, and an article to figure out how to do this in gnome-terminal and KConsole. But I can not find any solution in iTerm2 and Putty.

+7
source share
4 answers

This great Steve Losch plugin takes care of iTerm2. I do not know about Putty.

+2
source

The plugin from Steve Losh ( https://github.com/sjl/vitality.vim ) is slightly incorrect for some (it adds strange characters instead of the cursor when switching between tabs in iTerm2).

Adding this to your .vimrc works for me:

" Change cursor shape between insert and normal mode in iTerm2.app if $TERM_PROGRAM =~ "iTerm" let &t_SI = "\<Esc>]50;CursorShape=1\x7" " Vertical bar in insert mode let &t_EI = "\<Esc>]50;CursorShape=0\x7" " Block in normal mode endif 

The loan goes to Erland Humberg: http://hamberg.no/erlend/posts/2014-03-09-change-vim-cursor-in-iterm.html

0
source

I have been using this plugin for a long time, and it works great with Konsole, but also supports many terms.

The documentation says:

Currently, iTerm2 terminals for Mac are supported (version 1.0.0.20130602 beta or better), VTE3-based terminals (including the gnome terminal), and KDE Konsole. The xterm console is also supported. The older xterm did not support the line cursor, so this plugin currently sets the cursor to underline instead.

Older versions of VTE3-based terminals (up to version 0.39) do not support changing the cursor via escape sequences and are not supported. For unsupported terminals, the default behavior of Vim remains unchanged.

The plugin also supports tmux and will change the cursor inside the tmux session.

0
source

I think you should not install any plugins, you can change [dragging putty] → Window-> Appearance → [Cursor appearance] → [Vertical line],

it is more convenient.

And I think that changing the vim cursor is not necessary, because it is unlikely to find the cursor if you change the shape!

-one
source

All Articles