1.vim快捷键
编辑模式(i o a R) | 命令模式(:、 ?/) | 一般模式(直接输入) | ||||
复制 | yy;yny | 复制 复制光标所在行;复制所在行之后n行 | 保存 | w | 光标移动 | 方向键;h,j,k,l |
粘贴 | p | 在光标所在行之前的行粘贴 | 退出 | q | 删除 | dd;ndd |
插入 | i;a;o I;A;O | 在光标前;后;下一行插入 在行首;行末;上一行插入 | 保存后退出 | wq;x | 重复操作 | . |
替换 | cc | 替换当前行 | 强制命令 | !q;!wq | 撤销 | u;ctrl+r |
删除 | x X | 删除光标所在字符 删除光标前字符 | 剪贴板粘贴模式 | set paste | 快速移动光标 | G:到行首;nG:到第n行首 n+/n-:下/上移n行 0/$:当前行首/尾 |
进入Visual Mode | v | 翻页 | Ctrl+u,f:向上半/一页 Ctrl+d,b:向下半/一页 | |||
搜索 | /x; n下一个,shift n上一个 |
2.vim界面设置
打开: vi ~/.vimrc,插入:
1set nocompatible " don't bother with vi compatibility "
2 set autoread " reload files when changed on disk, i.e.
3 set shortmess=atI
4 set magic " For regular expressions turn magic on "
5 set title " change the terminal's title "
6 set nobackup " do not keep a backup file "
7 set noerrorbells " don't beep "
8 set visualbell t_vb= " turn off error beep/flash "
9 set t_vb=
10 set timeoutlen=500
11
12
13 set encoding=utf-8
14 set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1
15 set fileformats=unix,dos,mac
16 set termencoding=utf-8
17 set formatoptions+=m
18 set formatoptions+=B
19
20
21 set ruler " show the current row and column "
22 set number " show line numbers "
23 set nowrap
24 set showcmd " display incomplete commands "
25 set showmode " display current modes "
26 set showmatch " jump to matches when entering parentheses "
27 set matchtime=2 " tenths of a second to show the matching parenthesis "
28
29 set hlsearch " highlight searches "
30 set incsearch " do incremental searching, search as you type "
31 set ignorecase " ignore case when searching "
32 set smartcase " no ignorecase if Uppercase char present "
33
34 set expandtab " expand tabs to spaces "
35 set smarttab
36 set shiftround
37 set autoindent smartindent shiftround
38 set shiftwidth=4
39 set tabstop=4
40 set softtabstop=4
41
42
43 set cursorcolumn
44 set cursorline
45
46 filetype on
47 syntax on
48 filetype plugin on
49
50 set filetype=c
51
52 color desert
53 set guifont=Courier\ 20
54 set foldmethod=indent