Vim Editor Assistant

Start vi Editor

vi file
// Opens 'file' in vi, or creates a file named 'file' if it does not exist.
vi file1 file2
// Opens files sequentially.
view file
// OPens 'file' in read-only mode.
vi -R file
// Opens 'file' in read-only mode.
vi -r file
// Recovers 'file' after system crash.
vi + file
// Opens 'file' at last line.

Exit vi Editor

ZZ
// Saves changes and exits.
:x
// Saves changes and exits.
:wq
// Saves changes and exits.
:w
// Saves changes.
:q
// Quit.
:q!
// Quit without saving changes.
:wq file
// Saves as 'file' and exits.

Insert, append

i
// Insert text before cursor.
I
// Insert text at beginning of current line.
a
// Append text after cursor.
A
// Append text at the end of current line.
o
// Open and insert text in new line below current line.
O
// Open and insert text ine new line above current line.
r
// Replace single character at cursor position.
R
// Replace multiple character starting with character at cursor position.
s
// Substitute a single character.
S
// Substitute entire line.

Delete

x
// Deletes a single character at cursor position.
X
// Deletes a single character before cursor positon.
dw
// Deletes from cursor position to next word.
dd
// Deletes entire line cursor is on.
D
// Deletes remainder of line, starting at cursor position.
[Ctrl] u
// Deletes from cursor to beginning of line.
d$
// Deletes from cursor to end of line.
d^
// Deletes to first character in line, preserving indentation.
ndd
// Deletes n number of lines (2dd deletes 2 lines).
nx
// Deletes n number of characters, starting with character under cursor (2x deletes 2 characters).

Yank, Copy

yw
// Yank word.
yy
// Yank current line.
:y
// Yank current line.
y^
// Yank from cursor to first character of line.
y0
// Yank from cursor to beginning of line.
y$
// Yank from cursor to end of line.
Y
// Yank current line.
nyy or nY
// Yank n number of lines (2yy or 2Y copies 2lines).

Paste

p
// Paste after cursor.
P
// Paste before cursor.
/word
// Search forward for 'word'.
?
// Repeats previous '/' search.
n
// Repeat last search in same direction.
N
// Repeat last search in opposite direction.
*
// Search forward for word under the cursor.
#
// Search backward for word under the cursor.
fx
// Search forward for next 'x' on same line.
Fx
// Search backward for previous 'x' on same line.
tx
// Search forwark for character before next 'x'.
Tx
// Search backward for character after previous 'x' on same line.

Move cursor

H
// Move to highest visible line on screen (top line).
M
// Move to middle of screen (center).
L
// Move to lowest visible line on screen (bottom line).
l 
// Move right.
h
// Move left.
K
Move up.
j
Move down.
^ 
// Move to first character on current line.
$
// Move to last column on current line.
0
// Move to first column on current line.
+
// Move to first character on next line.
-
// Move to first character on previous line
w
// Move to beginning of next word.
b
// Move to beginning of previous word.
(
// Move to beginning of current sentence.

)
// Move to beginning of next sentence.
{
// Move a paragraph back.

}
// Move a paragraph forward.
G
// Move to first character on last line.

gg
// Move to first character on first line.

Move screen

[Ctrl] d
// Move backward half screen.

[Ctrl] f
// Move backward full screen.

[Ctrl] u
// Move forword half screen.

[Ctrl] b
// Move forward full screen.

[Ctrl] e
// Move up one line.

[Ctrl] y
// Move down one line.
G
// Move to last line in file.

nG
// Move to n number line.

Other

.
// Repeat last edit command.
u
// Undo last change.

U
// Undo all changes on line.
[Ctrl] g
// Show current filename and line count.
:f
// Show current filename and line count.
:f filename
// Rename current file to 'filename'.
:cd dirname
// Change directory to 'dirname'.
~
// Change character case.
:.=
// Show current line number.
:=
// Show total number of lines.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值