Vim is a terminal text editor. It is an extended version of vi with additional features, including syntax highlighting, a comprehensive help system, native scripting (Vim script), a visual mode for text selection, comparison of files (vimdiff(1)), and tools with restricted capabilities such as rview(1) and rvim(1).
Vim stands for Vi IMproved. Most of Vim was made by Bram Moolenaar, but only through the help of many others.
to move the cursor forward to the start of the next word
b
to move the cursor backward to the start of the previous word
e
to move the cursor forward to the end of the next word
ge
to move the cursor backward to the end of the previous word
0
to move the cursor to the very first character of the line
$
to move the cursor to the end of a line
^
to move the cursor to the first non-blank character of the line
one of the most useful movement commands
single-character search command
fx
searches forward in the line for the single character x
Fx
the backward version of fx command
tx
works like the fx command, except it stops one character before the searched character.
Tx
the backward version of tx command
%
括号()[]{}匹配跳转
G
跳转到末行
nG
跳转到n行
gg
跳转到首行
H
移动光标到当前页的第一行
M
移动光标到当前页的中间行
L
移动光标到当前页的最后一行
to scroll one line at a time
一次滚动一行
CTRL-E
scroll up
CTRL-Y
scroll down
To scroll a whole screen at a time
一次滚动一屏
CTRL-F
To scroll forward
CTRL-B
To scroll backward
zz
To see the context of the line with the cursor
将光标所在行滚动到屏幕中间位置
zt
put the cursor line at the top
zb
put the cursor line at the bottom
simple searches
*
从上往下搜索光标所在单词
#
从下往上搜索光标所在单词
/include
n 从上往下搜索 include
N 从下往上搜索 include
3/include
goes to the third match of include
?include
n 从下往上搜索 include
N 从上往下搜索 include
4?include
goes the the fouth match of include
.*[]^%/\?~$
特殊字符需要使用 \ 转义
<\
only matches at the begining of a word
\>
only matches the end of a word
/the\>
搜索 the 结尾的单词
/<\the
搜索 the 开头的单词
/<\the\>
仅搜索 the
/the$
以 the 开头的行
/^the
以 the 结尾的行
/^the$
仅有 the 的行,前后不能有空格等其他字符
c.m
com、cam、cum等
the\.
转义点 搜索 the.
named marks
ma
marks the place under the cursor as mark a
:marks
查看所有marks;最多设置26个marks a到z
`a
反引号移动到 a mark 所在位置
’a
单引号 移动到 a mark所在行的开头
:set ignorecase
搜索时忽略大小写
:set noignorecase
搜索时不忽略大小写
:set hlsearch
高亮显示搜索结果
:set nohlsearch
关闭高亮
:nohlsearch
only remove the highlight
does not reset the option
This is a line with example text
x-->-->->----------------->
w w w 3w
This is a line with example text
<----<--<-<---------<--x
b b b 2b b
This is a line with example text
<----<----x---->------------>
2ge ge e 2e
^
<-----------x
.....This is a line with example text
<----------------x x-------------->
0 $
To err is human. To really foul up you need a computer.
---------->--------------->
fh fy
To err is human. To really foul up you need a computer.
--------------------->
3fl
To err is human. To really foul up you need a computer.
<---------------------
Fh
To err is human. To really foul up you need a computer.
<------------ ------------->
Th tn
%
<----->
if (a == (b * c) / d)
<---------------->
%
| first line of a file ^
| text text text text |
| text text text text | gg
7G | text text text text |
| text text text text
| text text text text
V text text text text |
text text text text | G
text text text text |
last line of a file V
+---------------------------+
H --> | text sample text |
| sample text |
| text sample text |
| sample text |
M --> | text sample text |
| sample text |
| text sample text |
| sample text |
L --> | text sample text |
+---------------------------+
+----------------+
| some text |
| some text |
| some text |
+---------------+ | some text |
| some text | CTRL-U --> | |
| | | 123456 |
| 123456 | +----------------+
| 7890 |
| | +----------------+
| example | CTRL-D --> | 7890 |
+---------------+ | |
| example |
| example |
| example |
| example |
+----------------+
+------------------+ +------------------+
| earlier text | | earlier text |
| earlier text | | earlier text |
| earlier text | | earlier text |
| earlier text | zz --> | line with cursor |
| earlier text | | later text |
| earlier text | | later text |
| line with cursor | | later text |
+------------------+ +------------------+
/the
the solder holding one of the chips melted and the
xxx xxx xxx
/the$
the solder holding one of the chips melted and the
xxx
/^the
the solder holding one of the chips melted and the
xxx
c.m
We use a computer that became the cummin winter.
xxx xxx xxx
ter.
We use a computer that became the cummin winter.
xxxx xxxx
ter\.
We use a computer that became the cummin winter.
xxxx
| example text ^ |
33G | example text | CTRL-O | CTRL-I
| example text | |
V line 33 text ^ V
| example text | |
/^The | example text | CTRL-O | CTRL-I
V There you are | V
example text
' The cursor position before doing a jump
" The cursor position when last editing the file
[ Start of the last change
] End of the last change
To err is human. To really foul up you need a computer.
------------------>
d4w
To err is human. you need a computer.
###
To err is human. you need a computer.
-------->
d2e
To err is human. a computer.
###
To err is human. a computer.
------------>
d$
To err is human
###
To err is human
------->
c2wbe<Esc>
To be human
###
c the change operator
2w move two words (they are deleted and Insert mode started)
be insert this text
<Esc> back to Normal mode
###
x stands for dl (delete character under the cursor)
X stands for dh (delete character left of the cursor)
D stands for d$ (delete to end of the line)
C stands for c$ (change to end of the line)
s stands for cl (change one character)
S stands for cc (change a whole line)
###
there is somerhing grong here
rT rt rw
There is something wrong here
###
There is something wrong here
5rx
There is something xxxxx here
###
To <B>generate</B> a table of <B>contents
f< find first < --->
df> delete to > -->
f< find next < --------->
. repeat df> --->
f< find next < ------------->
. repeat df> -->
###
/four<Enter> find the first string "four"
cwfive<Esc> change the word to "five"
n find the next "four"
. repeat the change to "five"
n find the next "four"
. repeat the change
etc.
###
teh th the
x p
###
x delete character under the cursor (short for "dl")
X delete character before the cursor (short for "dh")
D delete from cursor to end of line (short for "d$")
dw delete from cursor to next start of word
db delete from cursor to previous start of word
diw delete word under the cursor (excluding white space)
daw delete word under the cursor (including white space)
dG delete until the end of the file
dgg delete until the start of the file
set nu
set nocompatible
set laststatus=2
set statusline=%F%m%r%h%w%=(%{&ff}/%Y)\ (line\ %l\/%L,\ col\ %c)
set linespace=3
set cursorline
set cursorcolumn
highlight CursorLine term=reverse,bold cterm=reverse,bold ctermfg=DarkGray ctermbg=black guibg=Grey90
highlight CursorColumn term=reverse,bold cterm=reverse,bold ctermfg=DarkGray ctermbg=black guibg=Grey90
syntax enable
filetype plugin indent on
let g:rustfmt_autosave = 1
" 将当前行向上移动一行
inoremap <M-k> <Esc>kddpk
nnoremap <M-k> kddpk
" 将当前行向下移动一行
inoremap <M-j> <Esc>ddp
nnoremap <M-j> ddp
set ff=unix
" 去掉有关vi一致性模式,避免以前版本的bug和局限
set nocompatible
" indent :set indent :set ai等自动缩进,想使用backspace将字段缩进的删除,必须设置这个选项。否则不响应
" eol 如果 insert 模式再行开头想使用backspace合并两行,需要设置eol
" start 想要删除此次插入前的输入,需要设置start
set backspace=indent,eol,start
set nu
set guifont=JetBrains_Mono_SemiBold:h12
set laststatus=2 "显示状态栏
set statusline=%F%m%r%h%w%=(%{&ff}/%Y)\ (line\ %l\/%L,\ col\ %c)
"上面的状态栏展示信息比较多,,可以如上所示进行集合性配置,如果懒得一一理解,可直接复制进配置文件,因为所有配置对于提升你编程效率都有帮助。当然如果你不嫌麻烦,也可以以下面所示形式单独配置(注意去掉前面”号)
"set statusline+=%{&ff} "显示文件格式类型
"set statusline+=%h "帮助文件标识
"set statusline+=%m "可编辑文件标识
"set statusline+=%r "只读文件标识
"set statusline+=%y "文件类型
"set statusline+=%c "光标所在列数
"set statusline+=%l/%L "光标所在行数/总行数
"set statusline+=\ %P "光标所在位置占总文件百分比
" Show a few lines of context around the cursor. Note that this makes the text
" scroll if you mouse-click near the start or end of the window.
set scrolloff=5
set linespace=3
" Don't use Ex mode, use Q for formatting.
map Q gq
" rust.vim start "
syntax enable
filetype plugin indent on
" let current_compiler = 'rustc'
let g:rustfmt_autosave = 1
let g:rustfmt_fail_silently = 0
" let g:syntastic_rust_checkers = ['cargo']
" rust.vim end"