如何解决Vim 电力线奇怪的不明字符正常 unix 100% 1:1
这是我使用的vim版本
vim --version
VIM - Vi IMproved 8.1 (2018 May 18,compiled Apr 15 2020 06:40:31)
Included patches: 1-2269
Modified by team+vim@tracker.debian.org
Compiled by team+vim@tracker.debian.org
Huge version without GUI. Features included (+) or not (-):
+acl -farsi -mouse_sysmouse -tag_any_white
+arabic +file_in_path +mouse_urxvt +tcl
+autocmd +find_in_path +mouse_xterm +termguicolors
+autochdir +float +multi_byte +terminal
-autoservername +folding +multi_lang +terminfo
-balloon_eval -footer -mzscheme +termresponse
+balloon_eval_term +fork() +netbeans_intg +textobjects
-browse +gettext +num64 +textprop
++builtin_terms -hangul_input +packages +timers
+byte_offset +iconv +path_extra +title
+channel +insert_expand +perl -toolbar
+cindent +job +persistent_undo +user_commands
-clientserver +jumplist +postscript +vartabs
-clipboard +keymap +printer +vertsplit
+cmdline_compl +lambda +profile +virtualedit
+cmdline_hist +langmap -python +visual
+cmdline_info +libcall +python3 +visualextra
+comments +linebreak +quickfix +viminfo
+conceal +lispindent +reltime +vreplace
+cryptv +listcmds +rightleft +wildignore
+cscope +localmap +ruby +wildmenu
+cursorbind +lua +scrollbind +windows
+cursorshape +menu +signs +writebackup
+dialog_con +mksession +smartindent -X11
+diff +modify_fname +sound -xfontset
+digraphs +mouse +spell -xim
-dnd -mouseshape +startuptime -xpm
-ebcdic +mouse_dec +statusline -xsmp
+emacs_tags +mouse_gpm -sun_workshop -xterm_clipboard
+eval -mouse_jsbterm +Syntax -xterm_save
+ex_extra +mouse_netterm +tag_binary
+extra_search +mouse_sgr -tag_old_static
system vimrc file: "$VIM/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
user exrc file: "$HOME/.exrc"
defaults file: "$VIMRUNTIME/defaults.vim"
fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONfig_H -Wdate-time -g -O2 -fdebug-prefix-map=/build/vim-iU6mZD/vim-8.1.2269=. -fstack-protector-strong -Wformat -Werror=format-security -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,Now -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,-E -Wl,Now -Wl,--as-needed -o vim -lm -ltinfo -lnsl -lselinux -lcanberra -lacl -lattr -lgpm -ldl -L/usr/lib -llua5.2 -Wl,-E -fstack-protector-strong -L/usr/local/lib -L/usr/lib/x86_64-linux-gnu/perl/5.30/CORE -lperl -ldl -lm -lpthread -lcrypt -L/usr/lib/python3.8/config-3.8-x86_64-linux-gnu -lpython3.8 -lcrypt -lpthread -ldl -lutil -lm -lm -L/usr/lib/x86_64-linux-gnu -ltcl8.6 -ldl -lz -lpthread -lm -lruby-2.7 -lm
这是我的 vimrc
.vimrc
set nocompatible
set incsearch
set hlsearch
set number relativenumber
set encoding=utf-8
set noswapfile
set smartindent
set undodir=~/.vim/undodir
set undofile
let mapleader = " "
Syntax enable
filetype plugin indent on
set path+=**
set wildmenu
let $RTP=split(&runtimepath,',')[0]
let $RC="$HOME/.vimrc"
" Ctrl-[ for finding deFinition
command! MakeTags !ctags -R .
augroup numbertoggle
autocmd!
autocmd BufEnter,FocusGained,InsertLeave * set relativenumber
autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber
augroup END
" Plugins will be downloaded under the specified directory.
call plug#begin('~/.vim/plugged')
" Declare the list of plugins.
Plug 'tpope/vim-sensible'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-repeat'
Plug 'junegunn/SEOul256.vim'
Plug 'preservim/nerdtree'
Plug 'ap/vim-css-color'
Plug 'ajmwagar/vim-deus'
Plug 'dbeniamine/cheat.sh-vim'
Plug 'valloric/youcompleteme'
Plug 'powerline/powerline',{'rtp': 'powerline/bindings/vim/'}
" List ends here. Plugins become visible to Vim after this call.
call plug#end()
set guifont=Source\ Code\ Pro\ for\ Powerline
set background=dark " Setting dark mode
colorscheme deus
解决方法
这个答案适用于希望仅在 Windows 终端的 vim 中安装 powerline 的所有人(使用 wsl Ubuntu 20.04)。我花了很长时间。
我遇到这个问题的原因是 Windows 终端字体中缺少字形。我尝试按照@romainl 建议的文档(https://powerline.readthedocs.io/en/latest/installation/linux.html#fontconfig)安装电力线字体,但这没有用。此外,我尝试从 github(https://github.com/powerline/fonts) 安装所有电力线字体,我运行了两个安装脚本。根据此 blog() 的 powershell 控制台中的 windows 和 Ubuntu WSL Machine 上的 Linux 根据文档。也没有用。
然后我偶然发现了 Microsoft(https://docs.microsoft.com/en-us/windows/terminal/tutorials/powerline-setup) 的一篇博客文章,其中该人安装了一个主题框架 oh-my-posh。但是,我既不想安装主题框架,也不想安装特殊版本的 git。此外,我只想在 vim 中安装 powerline,而不是在我的整个控制台中。这是我问自己的那一刻:我错过了什么吗?事实上,我确实捕捉到了一些细节。答案是安装包含缺失字形的 Cascadia Mono PL 字体 (https://github.com/microsoft/cascadia-code/releases)。只需下载 zip 并双击字体。此外,我必须在 windows 终端的 setting.json 中设置字体(可以在终端中按 (CTRL +,
) 打开)。您的设置应如下所示:
{
"guid": "{07b52e3e-de2c-5db4-bd2d-ba144ed6c273}","hidden": false,"name": "Ubuntu-20.04","fontFace": "Cascadia Code PL","padding" : "0,0","source": "Windows.Terminal.Wsl"
},
既然先决条件已经处理完毕,我可以谈谈您需要在 .vimrc 中设置的正确设置,以便在 vim 中使用 powerline。首先你应该使用插件管理器我推荐 vim-plug(https://github.com/junegunn/vim-plug) 只是因为它被维护并且我使用它。安装 vim-plug 后,您只需要在 .vimrc 的 import 语句之间添加以下一行:
Plug 'powerline/powerline',{'rtp': 'powerline/bindings/vim/'}
结论是wsl机器安装多少字体都没有关系,也不需要在windows终端设置guifont,因为它什么都不做。这就是为什么文档没有真正帮助的原因,因为它遗漏了一些我需要连接点的信息。
更新:
Windows 更改了字体命名,新的 Windows 终端设置页面中的新名称为 Cascadia Code PL Regular
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。