Search code examples
vim

Vim - change cursor in command line


I'm trying to change cursor from block to vertical bar (I-beam) when entering Vim command line.

I was trying with this separate codes:

" with these two codes nothing happens
autocmd CmdlineEnter * let &t_SI
autocmd CmdlineEnter * execute &t_SI

" this last one  produce "E20: Mark not set" error
autocmd CmdlineEnter * execute '!echo -ne "' . &t_SI . '"'

Is something like that even possible or vim uses same cursor for cmd line like it uses in normal mode.
I've changed normal mode (&t_EI) to vertical bar and in that case cursor was vertical bar in cmd line.

Can cursor be changed in cmd line regardles of normal mode?
Can someone help with this?


Solution

  • In Vim 8.2.0258 or newer, the echoraw() function can be used

    autocmd CmdlineEnter * call echoraw(&t_SI)
    autocmd CmdlineLeave * call echoraw(&t_EI)