Using block cursor in plain linux console but vim changes it back to underline

316 views
Skip to first unread message

Dave Wood

unread,
Dec 28, 2008, 7:21:16 AM12/28/08
to vim...@googlegroups.com
I have been using an escape code in my ~/.bashrc to make the cursor into a
block, which is much easier to see when searching through man pages etc.

Only problem is that vim changes it back to the default underline cursor. I
can't find the correct command to change the shape of the cursor in vim.
I've seen some remarks about 'guicursor' and 'termcap-cursor-shape' but
there doesn't seem to be a plain 'cursor' attribute that I can find and
trying to set 'termcap-cursor-shape' gives me an unknown variable error.

Any ideas?

--
For 20 dollars, I'll give you a good fortune next time ...

Ben Schmidt

unread,
Dec 28, 2008, 8:08:47 AM12/28/08
to vim...@googlegroups.com
Dave Wood wrote:
> I have been using an escape code in my ~/.bashrc to make the cursor into a
> block, which is much easier to see when searching through man pages etc.

I presume you're on a Unix-like system. If you're on Windows, perhaps
'guicursor' is relevant. But, assuming you're not...

What's the escape code?

You need to put it into the t_SI and/or t_EI options much like shown at

:help termcap-cursor-shape

i.e. with something like

let &t_SI = "\<Esc>]12;purple\x7"
let &t_EI = "\<Esc>]12;blue\x7"

but obviously with more shape than colour-related escapes.

Cheers,

Ben.

Dave Wood

unread,
Dec 28, 2008, 9:35:53 AM12/28/08
to vim...@googlegroups.com
On (00:08 29/12/08), Ben Schmidt <mail_ben...@yahoo.com.au> put forth the proposition:
>
>Dave Wood wrote:
>> I have been using an escape code in my ~/.bashrc to make the cursor into a
>> block, which is much easier to see when searching through man pages etc.
>
>I presume you're on a Unix-like system. If you're on Windows, perhaps
>'guicursor' is relevant. But, assuming you're not...

Linux.

>
>What's the escape code?

echo -ne "\033[?06;14;224c"

>You need to put it into the t_SI and/or t_EI options much like shown at
>
> :help termcap-cursor-shape
>
>i.e. with something like
>
> let &t_SI = "\<Esc>]12;purple\x7"
> let &t_EI = "\<Esc>]12;blue\x7"

I will expermiment with these, thanks.

>but obviously with more shape than colour-related escapes.
>
>Cheers,
>
>Ben.
>
>
>
>
>
--
Help stamp out and abolish redundancy.

Dave Wood

unread,
Dec 28, 2008, 9:49:59 AM12/28/08
to vim...@googlegroups.com
On (14:35 28/12/08), Dave Wood <da...@unrealize.co.uk> put forth the proposition:
>
>On (00:08 29/12/08), Ben Schmidt <mail_ben...@yahoo.com.au> put forth the proposition:
>>
>>Dave Wood wrote:
>>> I have been using an escape code in my ~/.bashrc to make the cursor into a
>>> block, which is much easier to see when searching through man pages etc.
>>
>>I presume you're on a Unix-like system. If you're on Windows, perhaps
>>'guicursor' is relevant. But, assuming you're not...
>
>Linux.
>
>>
>>What's the escape code?
>
>echo -ne "\033[?06;14;224c"
>
>>You need to put it into the t_SI and/or t_EI options much like shown at
>>
>> :help termcap-cursor-shape
>>
>>i.e. with something like
>>
>> let &t_SI = "\<Esc>]12;purple\x7"
>> let &t_EI = "\<Esc>]12;blue\x7"
>
>I will expermiment with these, thanks.

These codes just freak out vim. They print something in the status error
and leave bits of text in whichever window I'm working in. I presume that
this is because in the help section for termcap-cursor-shape they are used
for xterm. I am using the plain linux console without X at the moment.

>
>>but obviously with more shape than colour-related escapes.
>>
>>Cheers,
>>
>>Ben.
>>
>>
>>
>>
>>
>--
>Help stamp out and abolish redundancy.
>
>
>
--
[From an announcement of a congress of the International Ontopsychology
Association, in Rome]:

The Ontopsychological school, availing itself of new research criteria
and of a new telematic epistemology, maintains that social modes do not
spring from dialectics of territory or of class, or of consumer goods,
or of means of power, but rather from dynamic latencies capillarized in
millions of individuals in system functions which, once they have
reached the event maturation, burst forth in catastrophic phenomenology
engaging a suitable stereotype protagonist or duty marionette (general,
president, political party, etc.) to consummate the act of social
schizophrenia in mass genocide.

Tony Mechelynck

unread,
Dec 28, 2008, 9:56:33 AM12/28/08
to vim...@googlegroups.com
On 28/12/08 13:21, Dave Wood wrote:
> I have been using an escape code in my ~/.bashrc to make the cursor into a
> block, which is much easier to see when searching through man pages etc.
>
> Only problem is that vim changes it back to the default underline cursor. I
> can't find the correct command to change the shape of the cursor in vim.
> I've seen some remarks about 'guicursor' and 'termcap-cursor-shape' but
> there doesn't seem to be a plain 'cursor' attribute that I can find and
> trying to set 'termcap-cursor-shape' gives me an unknown variable error.
>
> Any ideas?
>

|termcap-cursor-shape| is not an option or a variable, it's a help tag.
If you had followed it (using ":help termcap-cursor-shape" without the
quotes), you would have seen that in Console Vim (other than Windows
console), instead of a cursor option there are two termcap codes, t_SI
(for Start Insert) to set the Insert-mode cursor, and t_EI (for End
Insert) to set the Normal-mode cursor.

If you didn't define these codes yourself (they aren't defined in
"standard" termcaps), then maybe your *x distribution dropped a system
vimrc on you. Check the ":version" output to see where it might be located.

In the Windows version of Console Vim, the 'guicursor' option (which,
again, you should have checked) can be used to set the height (but not
the width) of the cursor separately for all the same cases as in the GUI.

Best regards,
Tony.
--
"Dying is a very dull, dreary affair. And my advice to you is to have
nothing whatever to do with it."
-- W. Somerset Maugham

Tony Mechelynck

unread,
Dec 28, 2008, 10:03:49 AM12/28/08
to vim...@googlegroups.com
On 28/12/08 15:49, Dave Wood wrote:
> On (14:35 28/12/08), Dave Wood<da...@unrealize.co.uk> put forth the proposition:
>> On (00:08 29/12/08), Ben Schmidt<mail_ben...@yahoo.com.au> put forth the proposition:
>>> Dave Wood wrote:
>>>> I have been using an escape code in my ~/.bashrc to make the cursor into a
>>>> block, which is much easier to see when searching through man pages etc.
>>> I presume you're on a Unix-like system. If you're on Windows, perhaps
>>> 'guicursor' is relevant. But, assuming you're not...
>> Linux.
>>
>>> What's the escape code?
>> echo -ne "\033[?06;14;224c"
>>
>>> You need to put it into the t_SI and/or t_EI options much like shown at
>>>
>>> :help termcap-cursor-shape
>>>
>>> i.e. with something like
>>>
>>> let&t_SI = "\<Esc>]12;purple\x7"
>>> let&t_EI = "\<Esc>]12;blue\x7"

>> I will expermiment with these, thanks.
>
> These codes just freak out vim. They print something in the status error
> and leave bits of text in whichever window I'm working in. I presume that
> this is because in the help section for termcap-cursor-shape they are used
> for xterm. I am using the plain linux console without X at the moment.
>
>>> but obviously with more shape than colour-related escapes.
>>>
>>> Cheers,
>>>
>>> Ben.
>>>
>>>
>>>
>>>
>>>
>> --
>> Help stamp out and abolish redundancy.
>>
>>
>>

If you make sure these codes are undefined, Console Vim will never
change the cursor shape. This is the default and that's why I mentioned
a possible system vimrc in my reply of a few minutes ago. If such a
system vimrc exists, you can override it by

if has('unix') && !has('gui_running')
set t_SI= t_EI=
endif


Best regards,
Tony.
--
Those who educate children well are more to be honored than parents,
for these only gave life, those the art of living well.
-- Aristotle

Dave Wood

unread,
Dec 28, 2008, 10:31:52 AM12/28/08
to vim...@googlegroups.com
On (16:03 28/12/08), Tony Mechelynck <antoine.m...@gmail.com> put forth the proposition:
Might just as well set then undefined then. There is one thing I noticed -
if my TERM is set to 'linux' it changes cursor, but if I use xterm-xf86-v40
it doesn't change the cursor.

>
>
>Best regards,
>Tony.
>--
>Those who educate children well are more to be honored than parents,
>for these only gave life, those the art of living well.
> -- Aristotle
>
>
--
A recent study has found that concentrating on difficult off-screen
objects, such as the faces of loved ones, causes eye strain in computer
scientists. Researchers into the phenomenon cite the added
concentration needed to "make sense" of such unnatural three
dimensional objects ...

Matt Wozniski

unread,
Dec 28, 2008, 1:45:40 PM12/28/08
to vim...@googlegroups.com
On 12/28/08, Dave Wood wrote:

>
> On (16:03 28/12/08), Tony Mechelynck wrote:
>> If you make sure these codes are undefined, Console Vim will never
>> change the cursor shape. This is the default and that's why I mentioned
>> a possible system vimrc in my reply of a few minutes ago.

Unless, of course, some *other* code that vim sends changes the cursor shape...

> Might just as well set then undefined then. There is one thing I noticed -
> if my TERM is set to 'linux' it changes cursor, but if I use xterm-xf86-v40
> it doesn't change the cursor.

So, based upon this, the answer was easy enough to find. Just
looking at the output of 'infocmp -d linux xterm-xf86-v40'
I noticed:

cnorm: '\E[?25h\E[?0c', '\E[?25h'

Which, thanks to 'man 5 terminfo', you can explain as "To reset
the cursor to normal visibility, rather than invisible or very
visible, in a linux terminal, send the code '<Esc>[?25h<Esc>[?0c'.
To do the same for an xterm-xf86-v40 terminal, send the code
'<Esc>?25h'." This means that on a "linux" terminal, the cursor
shape will be reset to the default.

To change that, you could throw this into your ~/.vimrc:

if 1
let &t_ve = substitute(&t_ve, '\e[?\zs0c', '6;14;224c', 'g')
endif

That says "If the terminal's 've' attribute (which is the termcap
name for what terminfo calls 'cnorm') matches /\e[?0c/, replace
the 0c with 6;14;224c" - ie, use *your* prefered cursor type,
instead of the default cursor type. It's pretty likely that other
applications will also use cnorm, though, so you might want to
just change your 'cnorm' sequence in your terminfo database,
instead...

~Matt

Алексей Михайлов

unread,
Jun 11, 2017, 12:33:43 PM6/11/17
to vim_use, m...@drexel.edu
> To change that, you could throw this into your ~/.vimrc:
>
> if 1
> let &t_ve = substitute(&t_ve, '\e[?\zs0c', '6;14;224c', 'g')
> endif
>
> That says "If the terminal's 've' attribute (which is the termcap
> name for what terminfo calls 'cnorm') matches /\e[?0c/, replace
> the 0c with 6;14;224c" - ie, use *your* prefered cursor type,
> instead of the default cursor type. It's pretty likely that other
> applications will also use cnorm, though, so you might want to
> just change your 'cnorm' sequence in your terminfo database,
> instead...
>
> ~Matt

Dear sir, thank you so-so much...
Reply all
Reply to author
Forward
0 new messages