0

I've tried VsVim recently. One nice thing I noticed is when c or d is entered the cursor shape changes to half-underscore. And after deleting the line with dd cursor shape restores to block. Is it possible to add this feature to Vim?

Cursor change on <change>

0

In my case it was I think gvim, on Windows, which made me get used to a different cursor in normal and insert mode.

You did not specify any terminal; I made a small function in my .vimrc for linux console and xterm.

" Cursor shape ANSI-Codes
fu Cursor_tve()
if ($TERM == 'linux')
    au! InsertEnter * set t_ve=^[[?3;0;8c^[[?25h
    au! InsertLeave * set t_ve=^[[?192;7;50c^[[?25h
    " yellow
    "set t_ve=^[[?255;16;245c^[[?25h
endif

if ($TERM =~ 'xterm' )
    set t_SI=^[[4\ q
    set t_EI=^[[2\ q
    " for xterm: (just blink)
    "au! InsertEnter * set t_ve=^[[?25h^[[?12h
    "au! InsertLeave * set t_ve=^[[?12l^[[?25h
endif

endfu

(To call it I have call Cursor_tve() also in .vimrc.)

The t_SI for xterm is mentioned in vim's help, try :h t_SI. The escape sequence is also a bit hard to find.

For only one terminal type you can leave out the if ($TERM == part

As you see, I first had a yellow cursor. This was neither practical nor did it work well with the shell cursor. Now I have a full cursor for normal mode and a line (xterm) or a quarter block (linux).

  • When I press c or d key (before delete) there's no event <t_SI> yet. It happens after cw or c$ but not earlier. And I want to catch moment when only c or d key pressed. Maybe there's a special event name for these keys? – poulix Jan 9 at 20:27
  • I see...you want more than "c" or "d" bottom right indicating operator-pending mode. So after "dd" you get the normal block cursor restored. And after "cc"? Is there a special cursor indicating insert mode? – rastafile Jan 9 at 21:59
  • Actually, yes. And I don't see bottom right indicating operator-pending mode. Is it enabled by default? – poulix Jan 10 at 1:28
  • 1
    operator-pending mode is not affected by 'showmode' option - I don/t even know how to turn it off, in vim 8.1 :version 'huge-without-GUI'. With GUI (i.e. gvim?) you have option 'guicursor', where 0:hor50-Cursor is defined. I actually have it, but it doesn't work in non-GUI vim. This cursor shape thing is quite a portability issue...Did you try gvim, or do you insist on vim? – rastafile Jan 10 at 5:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.