Vim Usage Summary

Source: Internet
Author: User

Brief introduction:

Vim is a well-known, powerful, highly customizable text editor similar to VI, which improves and adds many features on the basis of VI. Vim is purely free software.

Three modes General mode:

Vim opens a file and goes into general mode.

Tail display

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://s3.51cto.com/wyfs02/M01/72/CF/ Wkiom1xtgtsjntbeaaau1lqugh8438.jpg "" 226 "height=" "/>

This mode can move the cursor, delete characters or lines, and copy or paste the file data.

Edit mode

Type the following keys to enter edit mode

I:insert, insertion
A:append,
O:new Line,
I: The beginning of the line
A: End of line
O: Above New CCB

Tail display

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; margin:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://s3.51cto.com/wyfs02/M02/72/CF/ Wkiom1xtgttgor42aaaoagdpu20265.jpg "" 206 "height="/>

command-line mode, aka last-line mode

:: Enter command line mode. Note one:

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; margin:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://s3.51cto.com/wyfs02/M00/72/CF/wKiom1XtgTST9G_ Baaaf1lqqhny112.jpg "" "Height="/> "

Movement of the operation cursor of VIM

Jump between characters

Hjkl-> left and right, arrow keys can also

Jump between words:
W: The first word of the word
E: The ending of the current or subsequent word;
B: The first word of the current or previous word;

#COMMAND:

In-line jump:
^: jumps to the first non-whitespace character at the beginning of a line;
0: Jump to the beginning of the line;
$: Jump to end of line;

Move between rows:
#G:
1G, GG
G

Move between sentences:
)
(

Move between paragraphs:
}
{

Edit operation

Character Editing commands:

X: Large x to remove a character forward, equivalent to backspace

x: Lowercase x Deletes one character backwards, equivalent to Del

#x: Remove the back # characters at the cursor location

XP: Swap the character at the cursor and a character position at the back

Delete command:

D:

d^ Delete all characters at the beginning of the cursor

d$ Delete all characters at the end of the line at the cursor

D0 Delete all characters at the beginning of the cursor

DG: Remove all characters from the last line of the cursor

D1G: Removes all characters from the first line of the cursor

DD: Delete cursor in the row

#COMMAND

Note: Deleting content is saved to the buffer by the VIM editor

Paste command: P (paste, put)

If the previously copied or deleted content is not a complete line:

P Lowercase: Paste at the back of the current cursor

P Capital: Paste at the front of the current cursor

If the copied content is a full row (can be more than one line)

P Lowercase: Pasted below the current cursor line

P Capital: Paste to the line above the current cursor

Copy command: Y, yank

Y:

YY: The line where the cursor is copied

#yy: Copy the Down # line where the cursor is located

Y1G: Copy the line of the cursor to the first line of all characters

YG: Copy the line from the cursor to the last line of all characters

y$: Copy all characters from the character of the cursor to the end of the line

y^: Copy all characters from the character of the cursor to the beginning of the line

Changing commands: C, change both file editing and mode conversion

C$,C^,C0,CB,

Ce,ce,cw

CC: Delete cursor line, enter insert mode

Undo the previous editorial work

U:undo

Undo the previous edit operation

#u

Ctrl+r Recovery of previous revocation work

.: Repeats an edit operation

Turn screen operation :

Ctrl+f: Screen down one page

Ctrl+b: Screen up one page

Ctrl+d: Screen moves down half page

Ctrl+u: Screen moves up half page

Last-line mode:

(1) Address, delimitation

: Start_pos,end_pos

#: Line #

#,#: From # line to # line

#,+#: From # Line to section #+ #行

.: When moving forward

$: Group after row

%: Full text, equivalent to 1,$

/PAT1/: The first time the line is matched to this pattern;

#,/pat1/: Starting from #, the first line to be matched by this pattern

/pat1/,/pat2/: The first line that is matched by this pattern to the row that is matched to the second time

You can follow the edit command:

Y,w,r

(2) Find

/pattern: Searching the tail

? PATTERN: Searching for the header

N: Same direction as command

N: Opposite direction of command

(3) Find and replace

S: In the last-line mode, the Find-and-replace operation is done within the bounds of the ground-setting

s/what to look for/replace with content/modifiers

What to look for: Available modes

What to replace: You cannot use a pattern, but you can use a back reference symbol to refer to what the grouping brackets in the preceding pattern match to;

\1, \2, ...

&: Refers to the entire content of the "What to find" matches;

Modifier:

I: Ignore case

G: Global Substitution

C: Prompt the user to confirm whether to replace

/: Used for delimiters, so, to find the content or replace with the content that appears in this symbol, to use \ to escape it, use format: \/

The delimiter can be replaced with other characters: @, #等, for example;

Multi-file Mode:

Vim FILE1 FILE2 ...

: N Edit Next file

: N Edit Previous file

: Files lists all the files that are currently open by this vim

: Next edit Next file

: First editing of a file

:p Rev Edit Previous file

: Last edit Final file

: Wqall Save and exit all open files

: Q!all force quit all open files

Multi-File Window segmentation:

Vim-o|-o FILE1 FILE2 ...

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; margin:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://s3.51cto.com/wyfs02/M02/72/CB/ Wkiol1xtg1-sao3maal7bkmyd2i879.jpg "" 578 "height=" 460 "/>

Ctrl+w, arrow (arrows) Toggle window

Single File Window segmentation:

Ctrl+w, S:split, horizontal split

Ctrl+w, v:vertical, vertical split

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; margin:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://s3.51cto.com/wyfs02/M02/72/CF/wKiom1XtgXGSYb_ Jaaeg_eer97c209.jpg "" 613 "height=" 259 "/>

Some of the working features of the custom vim:

(1) Line number

Display: Set Nu

Disabled: Set Nonu

(2) Bracket matching

Display: Set SM

Disabled: Set NOSM

(3) Auto indent:

Set AI

Set Noai

(4) Highlight Search

Set Hlsearch

Set Nohlsearch

(5) Syntax coloring

Syntax on

Syntax off

(6) Ignore character case

Set IC

Set Noic

Practice:

1. Re-use the Find replacement command to delete white space characters from the beginning of the file;

%s/^[[:space:]]//g

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://s3.51cto.com/wyfs02/M00/72/CF/ Wkiom1xtgxlas2puaaaapdpeaai334.jpg "" 103 "height=" 149 "/>650) this.width=650;" Style= "background-image:none; border-bottom:0px; border-left:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://s3.51cto.com/wyfs02/M01/72/CF/ Wkiom1xtgxkcua6oaaayq67tl4m422.jpg "" "height=" "/>"

2. Use the Find and Replace command to add a # to the beginning of the line beginning with a blank character for each line of the file; The original whitespace character is reserved;

%s/^\s\+/#&/g

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; margin:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://s3.51cto.com/wyfs02/M02/72/CF/ Wkiom1xtgxkstww8aaaeawzse-8851.jpg "" "height="/>650 "this.width=650; style=" Background-image:none; border-bottom:0px; border-left:0px; margin:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://s3.51cto.com/wyfs02/M00/72/CF/ Wkiom1xtgxlzm42uaaaiaxwatrm232.jpg "" Height= "/>"

3, replace the/etc/sysconfig/init in/tmp/functions file is/var/log;

%s#/etc/sysconfig/init#/var/log#g

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; margin:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://s3.51cto.com/wyfs02/M01/72/CF/ Wkiom1xtgxpjzxdtaafqqwujztk320.jpg "" 540 "height=" 198 "/>

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; margin:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://s3.51cto.com/wyfs02/M02/72/CF/ Wkiom1xtgxor9ogeaae3m1hpqmo482.jpg "" 503 "height=" 196 "/>

4. Delete the line at the beginning of the/tmp/functions file so # starts with # and at least followed by a blank character #

%s/^\ (#\) \ (\s\+\)/\2/g

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; margin:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://s3.51cto.com/wyfs02/M02/72/CF/ Wkiom1xtgxth5xpiaahfe15gzyq454.jpg "" 532 "height=" 388 "/>

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; margin:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://s3.51cto.com/wyfs02/M00/72/CB/ Wkiol1xtg56cxtmsaahfme9zuy0782.jpg "" 533 "height=" 394 "/>

Vim Usage Summary

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.