4

I am using PuTTY to connect over SSH to an Ubuntu server from my Windows 7 workstation. Once connected I am using the Vim installation from the Ubuntu server to edit files. I want the cursor to change when I go into and out of insert mode. Part of my .vimrc file is like this but it is not changing the cursor:

if &term =~ "xterm"
    echo "xTerm!!inate!"
    let &t_SI = "\<Esc>]12;purple\x7"
    let &t_EI = "\<Esc>]12;blue\x7"
endif

I know that the if statement is executing because of the echo.

EDIT: Actually I would prefer to change the cursor to be a vertical line like you can in the PuTTY settings rather than change the color, or maybe even do both. But just changing the color would be a lot better than nothing. Also I am willing to change terminals if there is another Windows 7 Professionsal 64 bit compatible terminal that can do this (preferably something free). Maybe Poderosa can do this?

1 Answer 1

5

Your example appears to work just fine using xterm, so I don't think it is your .vimrc that is the problem.

Digging a little deeper, it appears that PuTTY doesn't appear to implement the OSC escape code that you are using to change the colour of the cursor (see do_osc in terminal.c in the PuTTY sources). Browsing the sources, I couldn't find any other mechanism to do something similar, either. This means that there probably isn't going to be an easy way to get this working in PuTTY.

Your solutions are thus likely to be limited to:

  1. Trying to plead with the PuTTY authors to implement the relevant OSC escape code;
  2. Changing your terminal program; or
  3. Finding another way to let vim know what mode you are in.

I suspect the third is going to be the easiest, unfortunately.

6
  • Is there a different terminal that will let you change the cursor width or color? Jun 30, 2011 at 16:16
  • 1
    @INTPnerd Mintty. It's derived from PuTTY, but it's generally more compatible with xterm and does support the xterm colour sequences (except that it only supports colour values, not names). It also implements a control sequence for changing cursor style. See this tip on how to put that to use in vim. Mintty requires Cygwin or MSYS though.
    – ak2
    Jun 30, 2011 at 19:26
  • @ak2 Thanks! Mintty works for this, but there is an annoying delay before the cursor changes when changing modes. IDK if that's Mintty's fault or not... Jun 30, 2011 at 21:13
  • 1
    @INTPnerd That's vim's escape timeout. See the next tip on how to avoid it.
    – ak2
    Jul 1, 2011 at 3:04
  • 1
    @INTPnerd Ah, that's a bug then, introduced in version 0.9. The cursor shape is only updated when the cursor blinks or moves, whereas of course it should be updated right away.
    – ak2
    Jul 2, 2011 at 11:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .