測試環境 CentOS8
vim 預設會把 # (註解) 行使用 暗藍色,基本上從螢幕根本看不出來是什麼字(如下).
暫時的方式可以在 vim 按下 “ESC” 鍵到 命令列模式下以下指令將 color syntax highlighting 功能關閉.
:syntax off
如需打開
:syntax on
下面來修改一下預設的顏色設定 (預設 .vim 檔案置於 /usr/share/vim/vim80/colors/ ),這邊下載 kolor.vim 的顏色定義.
[root@localhost ~]# wget --no-check-certificate http://www.vim.org/scripts/download_script.php?src_id=21276 --2022-03-29 17:05:47-- http://www.vim.org/scripts/download_script.php?src_id=21276 Resolving www.vim.org (www.vim.org)... 44.237.4.221 Connecting to www.vim.org (www.vim.org)|44.237.4.221|:80... connected. HTTP request sent, awaiting response... 302 Found Location: https://www.vim.org/scripts/download_script.php?src_id=21276 [following] --2022-03-29 17:05:48-- https://www.vim.org/scripts/download_script.php?src_id=21276 Connecting to www.vim.org (www.vim.org)|44.237.4.221|:443... connected. HTTP request sent, awaiting response... 200 OK Length: unspecified [application/octetstream] Saving to: ‘download_script.php?src_id=21276’ download_script.php?src_id=21 [ <=> ] 13.93K 59.5KB/s in 0.2s 2022-03-29 17:05:49 (59.5 KB/s) - ‘download_script.php?src_id=21276’ saved [14260]
下載的名稱有點奇怪,修改一下.
[root@localhost ~]# mv 'download_script.php?src_id=21276' kolor.vim
個人 Color 顏色設定檔案放在 ~/.vim/colors
[root@localhost ~]# mkdir ~/.vim [root@localhost ~]# mkdir ~/.vim/colors [root@localhost ~]# cp kolor.vim ~/.vim/colors
如需所有人皆使用需置於 /usr/share/vim/vim80/colors/ 路徑.
[root@localhost ~]# cp kolor.vim /usr/share/vim/vim80/colors/
修改 /etc/vimrc 使用 kolor.vim 的顏色定義.
[root@localhost ~]# echo 'colorscheme kolor' >> /etc/vimrc
沒有解決問題,試試搜尋本站其他內容