Vim 使用 coloscheme 突出显示某些动作后的尾随空格

Vim 使用 coloscheme 突出显示某些动作后的尾随空格

问题

在 Vim 中设置颜色方案后(按照规定的方法将 colorscheme.vim 文件移动到 ~/.vim/colors),并执行多行移动(例如 Ctrl-D/Ctrl-U 表示向上/向下翻页),Vim 会突出显示部分甚至全部尾随空白。您可以通过此图像看到我所看到的内容:

Vim 中突出显示不正确]

我注意到其他移动也有类似的行为,例如“100j/k”移动大量线条。触发错误后,更多移动似乎会使问题更加严重。较小的移动似乎没有任何作用,直到它们开始移动屏幕。

已尝试

安装不同的配色方案来检查它是否是特定于方案的,在 Vagrant 框中尝试使用 Vim 来查看它是否是我的计算机。

搜索 Google、Stack Overflow、超级用户——令人惊讶的是没有找到任何类似的东西。

环境

Surface Pro 上的 Windows 10。在 Windows (WSL) 上使用 Ubuntu Bash。Vim 8.0。尝试使用 molokai.vim 和 rigel.vim colorschemes。这是我的 vimrc:

set ruler
set number
set textwidth=80

" Creates tabs:
set softtabstop=4
set shiftwidth=4
set expandtab " whether tabs are tabs or spaces
set autoindent

syntax enable
set wildmenu " visual autocomplete menu <tab>/<alt-tab> to cycle
set incsearch " search as characters are entered
set hlsearch " highlights search results
" turn off search highlight, since it persists, with: \<space>
nnoremap <leader><space> :nohlsearch<CR>
colorscheme rigel

答案1

可能有点晚了,但可能会对其他人有所帮助。我通过从 vimrc 中删除此行解决了此问题:

set listchars=nbsp:█,eol:¶,tab:>-,extends:»,precedes:«,trail:• 

答案2

我在另一篇文章中看到了这个答案,我遇到了同样的问题,但这不是 listchars 选项的问题。这解决了所有问题:添加autocmd VimEnter * set t_ut= to your vimrc file

答案3

这是我尝试解决同一问题时看到的第一个帖子,因此我认为用对我有用的方法更新这个问题是个好主意。

当我向下滚动页面时,似乎我的 vim 配色方案正在让位于我的终端(kitty)配色方案。幸运的是,我偶然发现了一个关于 kitty 的 GitHub 问题

添加以下内容.vimrc对我来说解决了这个问题。

" vim hardcodes background color erase even if the terminfo file does
" not contain bce (not to mention that libvte based terminals
" incorrectly contain bce in their terminfo files). This causes
" incorrect background rendering when using a color theme with a
" background color.
let &t_ut=''

相关内容