Vim suddenly lost its color, troubleshooting.

Vim was working fine yesterday, but suddenly it lost its color today, what’s the matter?

It is not a common $TERM variable problem on the Internet.
Troubleshooting process:
$ ldd vim
 ./vim: /lib/x86_64-linux-gnu/libtinfo.so.5: no version information available (required by ./vim)
 has a warning

View in vim
: scriptnames
display
1: ~/.vimrc
2: /opt/share/vim/vim74/ftoff.vim
3: ~/.vim/filetype.vim
4: /opt/share/vim/vim74/filetype.vim

The correct one should include the syntax script, as follows:
1: ~/.vimrc
2: /opt/share/vim/vim74/ftoff.vim
3: /opt/share/vim/vim74/syntax/syntax.vim
4: /opt /share/vim/vim74/syntax/synload.vim
5: /opt/share/vim/vim74/syntax/syncolor.vim
6: ~/.vim/filetype.vim

Check the ~/.vimrc file, check the suspicious variables one by one, and find that the &t_Co variable is not normal, use :echo &t_Co to check, the variable will flash, and the correct one should display 256. Enable the :syntax on command, it is still black and white, the keyword is just added underlined. This is easy because scripts such as syntax.vim are not loaded at all.

It is determined that the vim execution environment has been damaged, not a problem with the script. Thinking of the warning of libtinfo5, I decided to reinstall libtinfo5

Solution:
reinstall libtinfo5, the problem is solved, and the color is restored!
$ sudo apt install libtinfo5

Answer:
It can be seen that libtinfo5.so affects the operation of vim.
The problem should be that when I uninstall the package, libtinfo5 is uninstalled, and vim cannot run (this is a manually compiled version).
I copied a libtinfo5.so from another machine. , vim works, but the colors are lost.
The correct way is to use apt to install the missing package on this machine, and don’t just copy the so files on other machines.
Because the versions may be different, one is ubuntu18 and the other is ubuntu20

Guess you like

Origin blog.csdn.net/hejinjing_tom_com/article/details/128873351