admin管理员组

文章数量:1530873

2024年5月22日发(作者:)

基础

:e filename

:w

:q

:q!

:x

:sav filename

.

5.

Open

filename

for edition

Save file

Exit Vim

Quit without saving

Write file (if changes has been made) and exit

Saves file as

filename

Repeats the last change made in normal mode

Repeats 5 times the last change made in normal mode

在文件中移动

k or Up Arrow move the cursor up one line

j or Down Arrow move the cursor down one line

e

b

0

G

gg

L

:59

20|

%

[[

[{

move the cursor to the end of the word

move the cursor to the begining of the word

move the cursor to the begining of the line

move the cursor to the end of the line

move the cursor to the begining of the file

move the cursor to the end of the file

move cursor to line

59

. Replace

59

by the desired line number.

move cursor to column

20

.

Move cursor to matching parenthesis

Jump to function start

Jump to block start

剪切、复制和粘贴

y

p

dd

Copy the selected text to clipboard

Paste clipboard contents

Cut current line

yy

y$

D

Copy current line

Copy to end of line

Cut to end of line

搜索

/word

?word

*

/cstring

/jo[ha]n

/< the

/the>

/< the>

/< ¦.>

/

/fred|joe

/

/^n{3}

:bufdo /searchstr/

Search

word

from top to bottom

Search

word

from bottom to top

Search the word under cursor

Search

STRING

or

string

, case insensitive

Search

john

or

joan

Search the, theatre or

then

Search

the

or

breathe

Search

the

Search all words of 4 letters

Search

fred

but not

alfred

or

frederick

Search

fred

or

joe

Search exactly 4 digits

Find 3 empty lines

Search in all open files

Search

something

in all the open buffers and

bufdo %s/something/somethingelse/g

replace it with

somethingelse

替换

:%s/old/new/g Replace all occurences of

old

by

new

in file

:%s/onward/forward/gi Replace onward by forward, case unsensitive

:%s/old/new/gc

:2,35s/old/new/g

:5,$s/old/new/g

:%s/^/hello/g

Replace all occurences with confirmation

Replace all occurences between lines 2 and 35

Replace all occurences from line 5 to EOF

Replace the begining of each line by

hello

本文标签: 粘贴移动复制文件剪切