Loading ...
Sorry, an error occurred while loading the content.

Re: change cursor color by mode

Expand Messages
  • A. J. Mechelynck
    ... Yes, it is possible, using the guicursor option and possibly defining additional highlight groups. But is it useful? By default, the cursor is a vertical
    Message 1 of 3 , May 6 2:37 PM
    • 0 Attachment
      Jason Morehouse wrote:
      > Hello,
      >
      > Just wondering if it was possible to change the color (gvim) of the
      > cursor when in insert mode vs command mode?
      >
      > Thanks,
      > -Jason
      >
      >
      >
      Yes, it is possible, using the 'guicursor' option and possibly defining
      additional highlight groups. But is it useful? By default, the cursor is
      a vertical bar in Insert mode, an underline in Replace mode, a block in
      Normal mode; and in Command-line mode it is on the command line and not
      in the main screen area.

      The default 'guicursor' is:

      let &guicursor =
      \ "n-v-c:block-Cursor/lCursor,"
      \ . "ve:ver35-Cursor,"
      \ . "o:hor50-Cursor,"
      \ . "i-ci:ver25-Cursor/lCursor,"
      \ . "r-cr:hor20-Cursor/lCursor,"
      \ . "sm:block-Cursor"
      \ . "-blinkwait175-blinkoff150-blinkon175"

      To make the cursor red in Insert and Replace modes, or green if a keymap
      is in use, but not if on the command line, and in addition to make it
      blink on and off once per second (half a sec on, half a sec off) in all
      modes:

      if has("gui_running")
      hi RedCursor guibg=red guifg=bg
      hi GreenCursor guibg=green guifg=bg
      let &guicursor =
      \ "n-v-c:block-Cursor/lCursor,"
      \ . "ve:ver35-Cursor,"
      \ . "o:hor50-Cursor,"
      \ . "i:ver25-RedCursor/GreenCursor,"
      \ . "ci:ver25-Cursor/lCursor,"
      \ . "r:hor20-RedCursor/GreenCursor,"
      \ . "cr:hor20-Cursor/lCursor,"
      \ . "sm:block-Cursor,"
      \ . "a:blinkwait500-blinkoff500-blinkon500"
      endif

      You can paste the above "as is" (with linebreaks and all) in a vimrc or
      a colorscheme; though IMHO the default values distinguish the various
      cursor modes well enough. The if...endif wrapping is to avoid doing it
      in console Vim, which (depending on platform) either cannot set the
      cursor at all, or can only set its height but not its width.


      Best regards,
      Tony.
    Your message has been successfully submitted and would be delivered to recipients shortly.