将光标设置为vim中的垂直细线

mpo*_*ora 14 vim

我试图将插入模式中的光标设置为细垂直线,我无法.我在我的.vimrc文件中试过这个:

set guicursor+=i:ver100-iCursor
Run Code Online (Sandbox Code Playgroud)

在插入模式下,它不会将光标设置为垂直条.

我错过了什么,我该怎么做?

mpo*_*ora 13

这样就可以了:

set guicursor=i:ver25-iCursor

我不得不减少10025

  • @Nathan 在 Ubuntu 20.04 中,您可以通过选择光标 shape=i-beam 在终端上的首选项设置中更改它(右键单击终端中的任意位置并选择首选项)。 (3认同)

Eri*_*ski 13

/home/el/.vimrc在我的控制台工作的代码:

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
Run Code Online (Sandbox Code Playgroud)

这对我来说是这样的:

在此输入图像描述

资源:

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


mar*_*xor 11

对于 gnome 终端版本>3.15
将它添加到你的 ~/.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
Run Code Online (Sandbox Code Playgroud)

您将在正常模式下获得一个块光标,在插入模式下获得一个细光标。

在此处输入图片说明

  • 这对我也有用,但重绘很烦人。 (2认同)
  • 在 Vim8、Ubuntu 20.04 和 Gnome Terminal 3.36 上完美运行。 (2认同)