Ethan Zhang
Ethan Zhang

Reputation: 4479

How to change vim cursor shape in different modes

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

Upvotes: 8

Views: 4808

Answers (4)

Unarelith
Unarelith

Reputation: 495

I use this plugin since a long time, and it works perfectly with Konsole but it also supports a lot of terms.

The documentation says:

Currently supported terminals are iTerm2 for the Mac (version 1.0.0.20130602 beta or better is required), VTE3 based terminals (including gnome-terminal), and KDE's Konsole. The xterm console is partially supported as well. Older xterm's didn't support the line cursor, so this plugin currently sets the cursor to underline instead.

Older versions of VTE3 based terminals (before v0.39) do not support changing the cursor via escape sequences and are not supported. On unsupported terminals, Vim's default behavior is left unaltered.

The plugin also supports tmux, and will change your cursor inside a tmux session too.

Upvotes: 1

Markus Coetzee
Markus Coetzee

Reputation: 3444

The plugin by Steve Losh (https://github.com/sjl/vitality.vim) is a little buggy for some (adds weird characters in place of the cursor when you switch 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

Credit goes to Erlend Hamberg: http://hamberg.no/erlend/posts/2014-03-09-change-vim-cursor-in-iterm.html

Upvotes: 1

wcc526
wcc526

Reputation: 4105

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

it is more convenient.

And I think it is unnessary to change the vim cursor,because it will hardly find the cursor if you change the shape!

Upvotes: 0

romainl
romainl

Reputation: 196636

This plugin by the great Steve Losh takes care of iTerm2. I don't know about Putty.

Upvotes: 3

Related Questions