- 对当前用户编辑~/.vimrc,对所有用户编辑/etc/.vimrc,设置以下属性即可生效
# 设置显示行号
set nu
# 设置制表符为4位
set tabstop=4
# 位移操作宽度为4个空格的宽度
set shiftwidth=4
# 自动缩进
set autoindent
# 智能缩进
set smartindent
# 用空格代替tab
set expandtab
# 高亮所有搜索结果
set hlsearch
# 边输入边搜索
set incsearch
# 搜索时忽略大小写
set ignorecase
- 设置ubuntu系统默认编辑器为vim方法
sudo update-alternatives --config editor
#会出现下面提示让你选择
#有 4 个候选项可用于替换 editor (提供 /usr/bin/editor)。
# 选择 路径 优先级 状态
#------------------------------------------------------------
#* 0 /bin/nano 40 自动模式
# 1 /bin/ed -100 手动模式
# 2 /bin/nano 40 手动模式
# 3 /usr/bin/vim.basic 30 手动模式
# 4 /usr/bin/vim.tiny 10 手动模式
#要维持当前值[*]请按<回车键>,或者键入选择的编号:
- ubuntu自带的vim tiny版本方向键不正确问题解决方法
# 卸载系统自带vim
sudo apt-get remove vim-common
# 安装vim full版本
sudo apt-get install vim