Vim教程 (vimtutor)
命令模式 (Esc)
快捷键 |
全称 |
功能 |
H J K L |
- |
方向键,前面加数字代表移动多少行或列 |
:syntax on/off |
|
语法高亮 |
:set number |
|
开启行号 |
W |
word |
按单词移动 |
B |
back |
按单词返回移动 |
ctrl F |
forwad |
向下翻页 |
ctrl B |
backward |
向上翻页 |
Ngg |
goes to line |
跳转到指定行, 默认为首行 |
/pattern |
forward |
向下查找 |
N |
next |
查找下一个 |
shift N |
|
查找上一个 |
?pattern |
backward |
向上查找 |
cc |
cut |
剪切行,中间可加行数如c2c,默认1 |
u |
undo |
回撤 |
p |
paste |
粘贴 |
ctrl w |
window |
切换窗口 |
w filename |
|
保存为filename |
q |
quit |
退出 |
q! |
quit |
强制退出 |
视图模式 (v)
编辑模式 (i)
Vim-plug
- 更新host
# https://www.ipaddress.com/
185.199.108.133 raw.githubusercontent.com
185.199.109.133 raw.githubusercontent.com
185.199.110.133 raw.githubusercontent.com
185.199.111.133 raw.githubusercontent.com
- 下载vim-plug
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
- 编辑 .vimrc,添加NERD tree插件
vim ~/.vimrc
call plug#begin('~/.vim/plugged')
Plug 'scrooloose/nerdtree'
call plug#end()
- Vim安装插件
#注意结尾有!
:PluginInstall!
| 安装报错 unable to access ‘https://github.com/scrooloose/nerdtree.git/’
# 手动clone
~/.vim/plugged
git clone https://github.com/scrooloose/nerdtree.git/
| 报错 E492: Not an editor command: ^M
sudo apt install dos2unix
dos2unix ~/.vim/plugged/nerdtree/**/*.vim