注意 vim 所有控制指令都区分大小写。
| esc | 进入指令模式 |
| i | 编辑模式 |
| v | 光标区域选择模式,配合 hjkl 进行选择 |
| h | 光标左移 |
| l | 光标右移 |
| j | 光标下移 |
| k | 光标上移 |
| 0 零 | 移动到行首 |
| $ | 移动到行尾 |
| b | 移动到单词字首 |
| e | 移动到单词字尾 |
| H | 移动到当前屏幕最上方 |
| M | 移动到当前屏幕中间 |
| L | 移动到当前屏幕最下方 |
| gg | 移动到文档最上方 |
| G | 移动到文档最后 |
| ctrl f | 向下翻页 |
| ctrl b | 向上翻页 |
| u | 撤销上次操作 |
| dw | 删除这个单词后面的内容 |
| dd | 删除光标当前行 |
| dG | 删除光标后的全部文字 |
| d$ | 删除本行光标后面的内容 |
| d0 | 删除本行光标前面的内容 |
| y | 复制当前选中内容 |
| yy | 复制当前行 |
| p | 粘贴复制内容 |
| ddp | 当前行和下一行互换 |
| ggdG | 删除文档所有内容 |
| ~ | 当前光标字符大小写转换 |
| 查找指令 | |
| * | 向下查找同样光标的字符 |
| # | 向上查找同样光标的字符 |
| /string | 查找 string 一样的内容,向后 |
| ?string | 查找 string 一样的内容,向前 |
| n | 查找下一处 |
| N | 查找上一处 |
| 退出指令 | |
| :q | 一般退出 |
| :q! | 退出不保存 |
| :wq | 保存退出 |
| :set number | 显示行号 |
| :set nonumber | 取消行号 |
可以将自定义设置保持到配置文件,这样每次打开都会自动加载设置,配置文件地址为 ~/.vimrc,以下是我配置文件内容:
set number
syntax on
set autoindent
set tabstop=4也可以使用 GitHub 上别人做好的配置模板,直接复制到配置文件中即可:https://github.com/amix/vimrc/blob/master/vimrcs/basic.vim
]]>
国内使用 apt 安装软件如果感觉比较慢,可能是 deb 源是国外的,通过修改为国内源,可以很好的进行加速下载。
每一个版本的 Ubuntu 都会有一个代号: codename,用来识别不同的版本,比如:
在更换源的时候需要使用到代号codename,可以使用如下命令查看当前系统版本代号:
lsb_release -a
为防止修改错误或其他问题,将系统自带源文件进行备份很有必要,执行如下指令:
sudo cp /etc/apt/sources.list /etc/apt/sources.list_bak
打开 sources.list 文件,将内容修改为想要的国内源:
vim /etc/apt/sources.list
输入命令 ggdG 清空内容,修改为清华源加入如下内容:
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse可以看到每行内容里都有对应系统代号信息,如果要修改其他版本系统的 apt 源,只需要将里面系统代号替换即可。
常用国内源:
]]>