changing vim cursor shape or color in vim 7.0

370 views
Skip to first unread message

sinbad

unread,
Aug 17, 2011, 7:55:19 AM8/17/11
to vim_use
hi,

i'm using vim 7.0 inside a gnu screen.
i use vim by puttying to the linux server.
i want to change the cursor shape or color
whenever i want, basically i would like to
set the cursor to a different shape or color
when a variable is set. i tried experimenting
with t_ve option in vim. currently it is set to
t_ve=^[[34h^[[?25h, i don't know what those
values are, but i tried to change the numbers
with the hope that it might change either
color or shape of the cursor. but no matter
what vlaues i use the cursor just disappears.
i want to know what the values exactly mean
and how do i change them.

thanks
sinbad

sinbad

unread,
Aug 18, 2011, 2:26:04 AM8/18/11
to vim_use
can anyone please shed some light on this.

thanks

sinbad

unread,
Aug 26, 2011, 4:57:52 AM8/26/11
to vim_use
On Aug 18, 11:26 am, sinbad <sinbad.sin...@gmail.com> wrote:
can someone please give it a shot. i ran out of ideas !

thanks

Taylor Hedberg

unread,
Aug 26, 2011, 11:03:33 AM8/26/11
to vim...@googlegroups.com
sinbad, Wed 2011-08-17 @ 04:55:19-0700:

Those are terminal escape sequences. Modifying them isn't going to help
you at all, they should be set automatically based on the value of the
$TERM environment variable (in your case, "screen") and the contents of
your system's terminfo database.

You need to get Vim to actually emit those sequences if you want the
various effects. I know that you can set the values of 't_SI' and 't_EI'
as sequences to be emitted when entering and leaving insert mode,
respectively. I use those to turn my cursor green during insert mode,
using the following snippet in my .vimrc:

if &term =~ "xterm\\|rxvt" " Only apply this in xterm or rxvt-* terminals
silent !echo -ne "\033]12;white\007" " Initialize the cursor to white at startup
let &t_SI = "\033]12;green\007" " Turn the cursor green when entering insert mode
let &t_EI = "\033]12;white\007" " Turn the cursor white again when leaving insert mode
autocmd VimLeave * !echo -ne "\033]12;white\007" " Make sure the cursor is back to white when Vim exits
endif

As you see, you can just echo a literal escape sequence if you know the
one you want to use. You could probably use the "t_" variables in an
:execute command to get the same effect, but more portably across
terminals, e.g.:

silent execute '!echo -n "' . t_foo . '"'

That should echo the contents of the 't_foo' option to your terminal.
(It's completely untested though, so don't take my word for it.)

Perhaps someone else can fill in the gaps in my knowledge here, or maybe
that gives you enough to go on to figure it out yourself.

Taylor Hedberg

unread,
Aug 26, 2011, 11:11:27 AM8/26/11
to vim...@googlegroups.com
Taylor Hedberg, Fri 2011-08-26 @ 11:03:33-0400:

> silent execute '!echo -n "' . t_foo . '"'

Minor correction: At the very least, that should have been "&t_foo"
instead of "t_foo" in the above.

Marcin Szamotulski

unread,
Aug 27, 2011, 7:20:16 PM8/27/11
to vim...@googlegroups.com

These are my mappings to change cursor color (for vim in xterm):
map @1 :!echo -ne "\033]12;midnightblue\007"<CR><CR>
map @2 :!echo -ne "\033]12;grey100\007"<CR><CR>
map @3 :!echo -ne "\033]12;chartreuse1\007"<CR><CR>
map @4 :!echo -ne "\033]12;SlateBlue\007"<CR><CR>
You can check if that works for you.

Best,
Marcin
>
> --
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php

sinbad

unread,
Aug 29, 2011, 2:25:24 AM8/29/11
to vim_use
hi marcin,

thanks for sharing. but those mappings were not working for me.

Reply all
Reply to author
Forward
0 new messages