vimtricks.wiki Concise Vim tricks, one at a time.

How do I change the cursor shape to a thin bar in insert mode and a block in normal mode in Neovim?

Answer

:set guicursor=n-v-c:block,i-ci-ve:ver25,r-cr:hor20

Explanation

Neovim's guicursor option lets you assign a distinct cursor shape and style to each mode, providing immediate visual feedback about which mode you are in. Unlike terminal escape-code workarounds, guicursor is a native Neovim option that works in both GUI and modern terminals that support cursor-shape reporting.

How it works

The option takes a comma-separated list of {modes}:{shape} specifiers:

  • Modes are one or more mode flags joined with -: n (normal), v (visual), c (command), i (insert), r (replace), ci (command-insert), ve (visual-enter), cr (command-replace), o (operator-pending)
  • Shapes control appearance:
    • block — full-width block (traditional Vim look)
    • ver{N} — vertical bar at N% of cell width (e.g., ver25 = thin bar)
    • hor{N} — horizontal underline at N% of cell height (e.g., hor20 = thin underline)

Example

Add to your init.vim or init.lua:

" init.vim
set guicursor=n-v-c:block,i-ci-ve:ver25,r-cr:hor20,o:hor50
-- init.lua
vim.opt.guicursor = "n-v-c:block,i-ci-ve:ver25,r-cr:hor20,o:hor50"

This configuration gives you:

Mode Cursor
Normal, Visual, Command Block
Insert, Command-insert 25% vertical bar
Replace, Command-replace 20% underline
Operator-pending 50% underline

Tips

  • Append -blinkon500-blinkoff500 to a specifier to enable blinking: i:ver25-blinkon500-blinkoff500
  • To reset to the default, use :set guicursor&
  • This option is Neovim-only; in Vim, use terminal escape sequences (t_SI/t_EI) instead
  • :help 'guicursor' lists all valid flags and color group extensions

Next

How do I get just the filename without its path or extension to use in a command?