您的位置:首页 > 运维架构 > Linux

Linux vim 命令大全

2015-06-26 17:35 861 查看
在Linux上使用VIM,有很多命令,使用vimtutor查看命令指导手册。内容整理如下:

USING ALL OF THESE COMMANDS IN NORMAL MODEL!!!

:---enable to type commands at the bottom of scree.

:help---get help online document

:help+command

Ctrl+W---jump from one window to another

:q+<ENTER>---close the help window

:help vimrc-intro----to enable vim features by creating a vimrc  file for some settings

for command completion: ":set nocp" to ensure no compatible model, and then ":e" and press CTRL+D to show all commands started by e. and <TAB> is to complete the commands or paraments.

vimtutor---a guidance of vim usage

vim---open vim software

vim filename---open file as filename in vim software, if the file doesn't exits, it will create a new file.

i---insert text into vim, change from Normal model to Insert model

h---cursor move left

l---cursor move right

k---cursor move up

j---cursor move down

:w---save the file to current path

:q---exit vim without any save

:wq---exit vim with file saved

:q!---forcely exit vim without any save

<for text changes>

x---delete the char at the cursor

a---cursor move to next char and text can be appended there

A---cursor jumps to the end of this line and text can be appened after this line.

i/a/A---all enter the INSERT model, the diff is where cursor is.

p---paste from jieqieban

0---move cursor to the start of line.

dd---delete a line. with 2dd to delete 2 lines.

dw---delete a word at the cursor, the cursor jumps to the next word.

de---delete a word at the cursor, the cursor jumps before the next word.

d$---delete a line from current cursor, if part of this line in next row, this part can't be deleted.

<for text changes>

u---undo last command.

U---undo all the changes on a line

Crtl+R---to undo the undo's

p---put previously deleted line after the current cursor line.

r---replace the char where cursor is with the char typed

R---replace many chars where cursor is with chars typed

ce---change the word to its end where cursor is with the chars typed

Ctrl+g---show file name and cursor location(help ruler) in file

G---move cursor to the end of file

gg--move cursor to the start of file

<number>+g---move cursor to the "number" line of file

/+phrase---search phrase from top to bottom in the file, search next by typing "n", search last by typing "N". Go back to where you came from by typing "Ctrl+o". "?+phrase" to search from bottom to top.

%---move cursor to the matched side of ()/[]/{}.

:s/old/new+/g---replace old with new. "/g" means do this command globally in the line.

:<#/%>s/old/new+/g---# is line type. if it's %, replace old with new globally in the file. to ask for confirmation, type "c" after "/g".

:set ic+ searchcommand---ignore the case upper or lower, ":set

noic" to disable ingnoring

:set hls is+ searchcommand---highlight the phrase that matched,

"nohlsearch" to disable highlight.

:!+external command---execute an external shell command

v---select text to write in a Visual model.

:r+filename---retrieve the file

:r !dir---show direction content

o---open a line in INSERT model after cursor line.

O---open a line in INSERT model above cursor line.

append commands: press e to move to the incomplete word, press a to append.then repeate it.

copy and paste: press v to enter VISUAL model, select text and press y to copy, then move cursor to the target line, press p to paste it there.

<operator><motion>---like dw, de, d$, for them, d is operator, and w/e/$ is motion.

<number><motion>---repeat the motion "number" times.

<operator>[number]<motion>---combination groups commands to be more powerful, for example, d/c is operator, w/e/$ is motion.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: