Monday, May 27, 2019

Re: Cursor shape in the console

On Mon, 27 May 2019, Tony Mechelynck wrote:

> if only I knew the correct xterm bytecode to
> make the cursor a block, a vertical bar or an underscore.

Hi Tony,

Here's what I use for real xterm, and covering a pretty good span of Vim
releases (including those predating t_SR):

if has('cursorshape') && &term =~ '^xterm'
" Use a bar cursor in Insert mode

let &t_SI = "\<Esc>[6 q"

" Use a block cursor in Normal mode, and restore at Vim exit

let &t_EI = "\<Esc>[2 q"
let &t_te = &t_EI . substitute(&t_te, '\C' . &t_EI, '', 'g')

" Use t_SR for an underline cursor in Replace mode, if available (Vim
" 7.4.687 or newer); otherwise, change the value of t_SI when entering
" Insert or Replace mode, as appropriate.

if exists('&t_SR')
let &t_SR = "\<Esc>[4 q"
else
autocmd vimrc InsertChange,InsertEnter *
\ if v:insertmode == 'r' || v:insertmode == 'v' |
\ let &t_SI = "\<Esc>[4 q" |
\ else |
\ let &t_SI = "\<Esc>[6 q" |
\ endif
endif
endif


Those are the non-blinking variants in xterm. You'll probably need to
adjust that for non-xterm; there's a Vim wiki page[1] that suggests other
sequences for Konsole. Also note the &term test at the beginning.

-Rob


[1] https://vim.fandom.com/wiki/Change_cursor_shape_in_different_modes

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/alpine.LFD.2.21.1905280029540.2350%40bugs.loonybin.net.
For more options, visit https://groups.google.com/d/optout.

No comments: