解决Ubuntu22.04Desktop桌面版的vim的编辑模式下的上下左右变成ABCD 221019记录

371 阅读2分钟

解决Ubuntu22.04Desktop桌面版的vim的编辑模式下的上下左右变成ABCD

Ubuntu22.04Desktop桌面版的vim的编辑模式下的上下左右变成ABCD , 退格键也失效, 大名鼎鼎的vim也出现这种低级bug, 这也太开玩笑了吧, 还是Ubuntu故意为之?

解决办法1, 卸载重装vim

sudo apt remove vim
sudo apt install -y vim

解决办法2 , 修改 /etc/vim/vimrc.tiny

  1. 将 兼容模式 改为 不兼容模式 set compatible 改为 set nocompatible , 或加到后面
  2. 加入一条 set backspace=2

暂时没法用vi,vim , 可以用 nano 或 gedit 修改

远程用

sudo nano /etc/vim/vimrc.tiny

本机用

sudo gedit /etc/vim/vimrc.tiny

原先的 /etc/vim/vimrc.tiny

" Vim configuration file, in effect when invoked as "vi". The aim of this
" configuration file is to provide a Vim environment as compatible with the
" original vi as possible. Note that ~/.vimrc configuration files as other
" configuration files in the runtimepath are still sourced.
" When Vim is invoked differently ("vim", "view", "evim", ...) this file is
" _not_ sourced; /etc/vim/vimrc and/or /etc/vim/gvimrc are.

" Debian system-wide default configuration Vim
set runtimepath=~/.vim,/var/lib/vim/addons,/usr/share/vim/vimfiles,/usr/share/vim/vim82,/usr/share/vim>
set compatible

" vim: set ft=vim:

修改后的 /etc/vim/vimrc.tiny

" Vim configuration file, in effect when invoked as "vi". The aim of this
" configuration file is to provide a Vim environment as compatible with the
" original vi as possible. Note that ~/.vimrc configuration files as other
" configuration files in the runtimepath are still sourced.
" When Vim is invoked differently ("vim", "view", "evim", ...) this file is
" _not_ sourced; /etc/vim/vimrc and/or /etc/vim/gvimrc are.

" Debian system-wide default configuration Vim
set runtimepath=~/.vim,/var/lib/vim/addons,/usr/share/vim/vimfiles,/usr/share/vim/vim82,/usr/share/vim>

set nocompatible
set backspace=2

" vim: set ft=vim:

用脚本修改

echo '" Vim configuration file, in effect when invoked as "vi". The aim of this
" configuration file is to provide a Vim environment as compatible with the
" original vi as possible. Note that ~/.vimrc configuration files as other
" configuration files in the runtimepath are still sourced.
" When Vim is invoked differently ("vim", "view", "evim", ...) this file is
" _not_ sourced; /etc/vim/vimrc and/or /etc/vim/gvimrc are.

" Debian system-wide default configuration Vim
set runtimepath=~/.vim,/var/lib/vim/addons,/usr/share/vim/vimfiles,/usr/share/vim/vim82,/usr/share/vim>

set nocompatible
set backspace=2

" vim: set ft=vim:' | sudo tee /etc/vim/vimrc.tiny

或者

sudo sed -ie 's/compatible/nocompatible\nset backspace=2/'  /etc/vim/vimrc.tiny

查看并试验vim的上下左右

sudo vi /etc/vim/vimrc.tiny

还原

echo '" Vim configuration file, in effect when invoked as "vi". The aim of this
" configuration file is to provide a Vim environment as compatible with the
" original vi as possible. Note that ~/.vimrc configuration files as other
" configuration files in the runtimepath are still sourced.
" When Vim is invoked differently ("vim", "view", "evim", ...) this file is
" _not_ sourced; /etc/vim/vimrc and/or /etc/vim/gvimrc are.

" Debian system-wide default configuration Vim
set runtimepath=~/.vim,/var/lib/vim/addons,/usr/share/vim/vimfiles,/usr/share/vim/vim82,/usr/share/vim>
set compatible

" vim: set ft=vim:' | sudo tee /etc/vim/vimrc.tiny