Setting the cursor to a vertical thin line in vim

前端 未结 3 1837
离开以前
离开以前 2021-02-07 06:23

I am trying to set the cursor in insert mode to be a thin vertical line and I am unable to. I have tried this in my .vimrc file:

set guicursor+=i:ver100-iCursor         


        
相关标签:
3条回答
  • 2021-02-07 06:27

    For gnome terminal version>3.15
    Add this to your ~/.vimrc.

    if has("autocmd")
      au VimEnter,InsertLeave * silent execute '!echo -ne "\e[2 q"' | redraw!
      au InsertEnter,InsertChange *
    \ if v:insertmode == 'i' | 
    \   silent execute '!echo -ne "\e[6 q"' | redraw! |
    \ elseif v:insertmode == 'r' |
    \   silent execute '!echo -ne "\e[4 q"' | redraw! |
    \ endif
    au VimLeave * silent execute '!echo -ne "\e[ q"' | redraw!
    endif
    

    You will get a block cursor in normal mode and a thin one in insert mode.

    0 讨论(0)
  • This code in my /home/el/.vimrc worked for my console:

    if $TERM_PROGRAM =~ "iTerm"
        let &t_SI = "\<Esc>]50;CursorShape=1\x7" " Vertical bar in insert mode
        let &t_EI = "\<Esc>]50;CursorShape=0\x7" " Block in normal mode
    endif
    

    Which does this for me:

    Source:

    https://hamberg.no/erlend/posts/2014-03-09-change-vim-cursor-in-iterm.html

    0 讨论(0)
  • 2021-02-07 06:49

    This did the trick:

    set guicursor=i:ver25-iCursor

    I had to reduce the 100 to 25

    0 讨论(0)
提交回复
热议问题