Quantcast

Changing the shape of the cursor ?

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Changing the shape of the cursor ?

Tintin72-2

Hi,

In Vim under Windows, when I shift in insert mode, cursor turn to an
underscore _.
It's very handy cause I alway know wich mode I'm in.
Unfortunately when I run VIm under Linux (Ubuntu), cursor
remain the same (square) in command or insert mode and it's confused
me.

Is there any way to change the shape of the cursor when shifting in
insert mode ?


Thanks.
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Changing the shape of the cursor ?

Dominique Pellé

2009/2/11 Tintin72 wrote:

> Hi,
>
> In Vim under Windows, when I shift in insert mode, cursor turn to an
> underscore _.
> It's very handy cause I alway know wich mode I'm in.
> Unfortunately when I run VIm under Linux (Ubuntu), cursor
> remain the same (square) in command or insert mode and it's confused
> me.
>
> Is there any way to change the shape of the cursor when shifting in
> insert mode ?
>
>
> Thanks.

If you use gvim, the shape of the cursor should change when
switching to insert mode.  See ":help guicursor" for how you can
also customize this default behavior further.

If you use Vim in a terminal, you can't change the shape of the
cursor. However, you can change the color of the cursor.  It works
at least in xterm & rxvt but unfortunately does not work in
gnome-terminal, Kconsole and xfce4-terminal).   To do this,
just add the following lines in your ~/.vimrc:

if &term =~ "xterm\\|rxvt"
  :silent !echo -ne "\033]12;red\007"
  let &t_SI = "\033]12;orange\007"
  let &t_EI = "\033]12;red\007"
  autocmd VimLeave * :!echo -ne "\033]12;red\007"
endif

It will change the color of the cursor to red in command mode,
and orange in insert mode. See also ":help t_SI".

Cheers
-- Dominique

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Changing the shape of the cursor ?

Garrett Whelan

 It works
at least in xterm & rxvt but unfortunately does not work in
gnome-terminal, Kconsole and xfce4-terminal).   To do this,
just add the following lines in your ~/.vimrc:

if &term =~ "xterm\\|rxvt"
 :silent !echo -ne "\033]12;red\007"
 let &t_SI = "\033]12;orange\007"
 let &t_EI = "\033]12;red\007"
 autocmd VimLeave * :!echo -ne "\033]12;red\007"
endif

I've also verified that this works with Eterm, which isn't quite as integrated as gnome-terminal it's way more visually customizable than xterm.

Can anyone tell me what the code means? Besides the colors of course.

--Whaledawg


--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Changing the shape of the cursor ?

Tony Mechelynck
In reply to this post by Tintin72-2

On 11/02/09 10:02, Tintin72 wrote:

> Hi,
>
> In Vim under Windows, when I shift in insert mode, cursor turn to an
> underscore _.
> It's very handy cause I alway know wich mode I'm in.
> Unfortunately when I run VIm under Linux (Ubuntu), cursor
> remain the same (square) in command or insert mode and it's confused
> me.
>
> Is there any way to change the shape of the cursor when shifting in
> insert mode ?
>
>
> Thanks.

In gvim, or in Console Vim for Windows, you can do it with the
'guicursor' option, which is well documented in the Vim help itself.

In versions of Vim running in Console mode on other OSes than Dos /
Windows (and even Vim for Cygwin is "non-Windows" in this context IIUC),
you can change the aspect of the cursor between Normal and Insert modes
if you know the termcap codes to send for it. Which codes to use will
usually vary from one terminal to the next, and you have to get (if you
can find it) the documentation for whatever console terminal or terminal
emulator you want to use. The relevant Vim help paragraph is
|termcap-cursor-shape|. It gives some codes to change the cursor colour
on true xterm consoles, but as was found a day or two ago on this very
list, they don't apply to gnome-terminal, which pretends to be xterm but
isn't.


Best regards,
Tony.
--
Seleznick's Theory of Holistic Medicine:
        Ice Cream cures all ills.

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Changing the shape of the cursor ?

Matt Wozniski-2
In reply to this post by Garrett Whelan

On Wed, Feb 11, 2009 at 3:41 PM, Garrett Whelan wrote:

>
>>  It works
>> at least in xterm & rxvt but unfortunately does not work in
>> gnome-terminal, Kconsole and xfce4-terminal).   To do this,
>> just add the following lines in your ~/.vimrc:
>>
>> if &term =~ "xterm\\|rxvt"
>>  :silent !echo -ne "\033]12;red\007"
>>  let &t_SI = "\033]12;orange\007"
>>  let &t_EI = "\033]12;red\007"
>>  autocmd VimLeave * :!echo -ne "\033]12;red\007"
>> endif
>
> I've also verified that this works with Eterm, which isn't quite as
> integrated as gnome-terminal it's way more visually customizable than xterm.

Note that Eterm has had a history of horrific security vulnerabilities
(for instance, an application outputting "\033]6;73;xterm\007" would
cause xterm to be launched for 4 months of Eterm's lifetime...).  I
don't know that I would trust the author's ability to consider
security enough to trust their software as the only layer between me
and a malicious program...

> Can anyone tell me what the code means? Besides the colors of course.

See http://www.xfree86.org/current/ctlseqs.html - The escape sequence
is "Change text cursor color to".

~Matt

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Changing the shape of the cursor ?

panshizhu
In reply to this post by Tintin72-2

Tintin72 写道:

> Hi,
>
> In Vim under Windows, when I shift in insert mode, cursor turn to an
> underscore _.
> It's very handy cause I alway know wich mode I'm in.
> Unfortunately when I run VIm under Linux (Ubuntu), cursor
> remain the same (square) in command or insert mode and it's confused
> me.
>
> Is there any way to change the shape of the cursor when shifting in
> insert mode ?

This is specific to the terminal, for example, Konsole in KDE4 can
change the shape of cursor, try the following:

    let &t_SI = "\<Esc>]50;CursorShape=1\x7"
    let &t_EI = "\<Esc>]50;CursorShape=0\x7"

This will give what you want, if you are using ubuntu intrepid you can
simply run sudo apt-get install konsole.


--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Changing the shape of the cursor ?

Tony Mechelynck

On 13/02/09 01:45, pansz wrote:

> Tintin72 写道:
>> Hi,
>>
>> In Vim under Windows, when I shift in insert mode, cursor turn to an
>> underscore _.
>> It's very handy cause I alway know wich mode I'm in.
>> Unfortunately when I run VIm under Linux (Ubuntu), cursor
>> remain the same (square) in command or insert mode and it's confused
>> me.
>>
>> Is there any way to change the shape of the cursor when shifting in
>> insert mode ?
>
> This is specific to the terminal, for example, Konsole in KDE4 can
> change the shape of cursor, try the following:
>
>      let&t_SI = "\<Esc>]50;CursorShape=1\x7"
>      let&t_EI = "\<Esc>]50;CursorShape=0\x7"
>
> This will give what you want, if you are using ubuntu intrepid you can
> simply run sudo apt-get install konsole.

Anything similar for KDE3 konsole (konsole 1.6.6 in KDE 3.5.10)? The
above doesn't work for me (my cursor remains in block-shape in all
modes). Yet I double-checked it: ":set t_SI? t_EI?" now returns

   t_SI=^[]50;CursorShape=1^G
   t_EI=^[]50;CursorShape=0^G

with the ^[ and ^G in blue, meaning Escape and Bell respectively.


Best regards,
Tony.
--
Ladybug, ladybug,
Look to your stern!
Your house is on fire,
Your children will burn!
So jump ye and sing, for
The very first time
The four lines above
Have been put into rhyme.
                -- Walt Kelly

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Changing the shape of the cursor ?

panshizhu

Tony Mechelynck 写道:

>> This is specific to the terminal, for example, Konsole in KDE4 can
>> change the shape of cursor, try the following:
>>
>>      let&t_SI = "\<Esc>]50;CursorShape=1\x7"
>>      let&t_EI = "\<Esc>]50;CursorShape=0\x7"
>>
>> This will give what you want, if you are using ubuntu intrepid you can
>> simply run sudo apt-get install konsole.
>
> Anything similar for KDE3 konsole (konsole 1.6.6 in KDE 3.5.10)? The
> above doesn't work for me (my cursor remains in block-shape in all
> modes). Yet I double-checked it: ":set t_SI? t_EI?" now returns
>
>    t_SI=^[]50;CursorShape=1^G
>    t_EI=^[]50;CursorShape=0^G
>
> with the ^[ and ^G in blue, meaning Escape and Bell respectively.

You may have to port the code to KDE3 konsole yourself, since such kind
of "new feature" is not meant to go to KDE 3.5 series, which is in
feature freeze.



--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Changing the shape of the cursor ?

Tony Mechelynck

On 13/02/09 06:47, pansz wrote:

> Tony Mechelynck 写道:
>>> This is specific to the terminal, for example, Konsole in KDE4 can
>>> change the shape of cursor, try the following:
>>>
>>>       let&t_SI = "\<Esc>]50;CursorShape=1\x7"
>>>       let&t_EI = "\<Esc>]50;CursorShape=0\x7"
>>>
>>> This will give what you want, if you are using ubuntu intrepid you can
>>> simply run sudo apt-get install konsole.
>> Anything similar for KDE3 konsole (konsole 1.6.6 in KDE 3.5.10)? The
>> above doesn't work for me (my cursor remains in block-shape in all
>> modes). Yet I double-checked it: ":set t_SI? t_EI?" now returns
>>
>>     t_SI=^[]50;CursorShape=1^G
>>     t_EI=^[]50;CursorShape=0^G
>>
>> with the ^[ and ^G in blue, meaning Escape and Bell respectively.
>
> You may have to port the code to KDE3 konsole yourself, since such kind
> of "new feature" is not meant to go to KDE 3.5 series, which is in
> feature freeze.

Thanks but no thanks; I'm not compiling (nor am I foreseeing to compile
in the future) any software other than Vim. I guess I'll wait until SuSE
abandonss support of KDE3 (which I prefer ATM to KDE4).

Best regards,
Tony.
--
"Yes, that was Richard Nixon.  He used to be President.  When he left
the White House, the Secret Service would count the silverware."
                -- Woody Allen, "Sleeper"

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Loading...