Summarize Vim,find's advanced usage and bash content, as well as Disk Management and file system knowledge

Source: Internet
Author: User
Tags modifier


Vim operation in LINUX

Vim is a powerful editing tool in Linux. Vim is divided into three modes: 1 edit mode, 2 insert mode, 3 last line mode.

1.1: Edit mode.

I:insert inserts the first character that the edit cursor rests on.

A:append appends the second character to the cursor.

O:new line creates a blank row and creates a new line next to the cursor.

I: The beginning of the line.

A: At the end of the line.

O: Create a new blank line above the cursor.

Input mode Press es==== to edit the mode.

Edit Mode Press ': ' ===== to enter the last line mode.

Last-line mode press esc====== to edit the mode.


1.2 Open File Vim edit

vim/path/;

+#: #表示行, navigate to the line number.

+/pattern regular matches.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/C0/wKiom1XsT4vRx1--AAH0wtvq83Q249.jpg "title=" W1 " uy65~lm8qt382 (qf~0a0.png "alt=" Wkiom1xst4vrx1--aah0wtvq83q249.jpg "/>


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/72/C0/wKiom1XsUFmB0xIJAAFT27oajZ0481.jpg "title=" p9{z% C@1_j1o7wiz{r31]b0.png "alt=" Wkiom1xsufmb0xijaaft27oajz0481.jpg "/>


1.3 Turn off the vim command.


: Q Exits. : Wq save exit. : q! force quit, do not save. : Wq save exit. : X Save exit.


1.4 Cursor Jump


H: Move left. L: Move right. J: Move up. K: Move Down.

W: the cursor to the right one word word head.

E: The current right word ending.

B: The first word of the current or previous word.


1.5 In-line jump


^: Jump to a non-blank line at the beginning of the line.

O: Jumps to the beginning of the line.

$: Jumps to the end of the line.


1.6 Moving between rows

#G: Jumps to # line.

1g,gg: All jumps to the first line.

G: The last line.


2: Edit Command

2.1 Character editing


x: Deletes the character at which the cursor is located.

#X: Delete # lines.

XP: Restores the most recent operation.

RW: Replaces the character where the cursor is located, and W replaces the character.


2.2 Delete Command


DD: Deletes the line where the cursor is located.

DW: Deletes the entire word.

Undo previous action: U


2.3 Paste P


If the copied or deleted content is not a complete line.

P: Paste until the current cursor is positioned.

P: Paste at the front of the current cursor.

If the whole row

P: Paste until the current cursor is positioned.

P: Paste at the front of the current cursor.


2.4 Copy command


YY: Copies the entire row.

y$: Copy from cursor to end of line.

y^: Copy from cursor to beginning of line.

YW: Copy the character at the cursor stop.

#yy: Represents the down # line from the cursor.


2.5 Turn screen operation


Ctrl+f: one screen back.

Ctrl+b: one screen ahead.

Ctrl+d: Back half screen.

Ctrl+u: Forward half screen


2.6 Vim built-in tutorial vimtutor.


The last line mode of 3:vim


3.1 Address, delimitation


: Start_pos.end_pos

: #: # line

: #, #第几行到第几行.

:.: the current line.

: $: Last line.

/PAT1/: Global match.


3.2 Find and replace


/pattern: to the tail.

? Pattern: Proceed to the header.

N: With the command in the same direction, continue to find, first find the command, press N to continue to find the next

N: Search in the opposite direction of the command. Find it and look up the second one. Input/root, press n after? Root


3.3 Find and replace

S: Within the ground connection, complete the Find and replace action.

s/to find what to look for/replace the content/modifier.

You can use regular expressions for what you are looking for. The replaced content is not.

Modifier: I ignores case. G: Global substitution. C: The user's confirmation should be taken when replacing.

: N1,n2s/word1/word2/gic

%S/WORD1/WORD2/represents replacing the first word1 of each line


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/C1/wKiom1XsYE3Q7Xs_AAO9FXBV5-k307.jpg "title=" Q ' Uzlaqd]q (p[~r_{l1pcyp.png "alt=" Wkiom1xsye3q7xs_aao9fxbv5-k307.jpg "/>


Find root and change to admin

1, $s/root/admin/represents the first root of the match to be replaced by admin.

1, $s/root/admin/g represents a global replacement.


3.4 Multi-file mode:


Vim file File2 file3 ..... separate multiple files with a space

: Next Next file

: First File

:prev Previous file

: last file.

Single-File Widget window segmentation

Ctrl+w, S:split horizontal split.

Ctrl+w,v:vertical Vertical segmentation.


3.5 Customizing Some of the VIM's operating features:

Display line number: Set Nu

Disable line number: Set Nonu

(2) Auto indent:

Set AI

Set Noai

(3) highlight Search

Set Hlsearch

Set Nohlsearch

(4) syntax coloring

Syntax on

Syntax off

(5) Ignore character case

Set IC

Set Noic












Summarize Vim,find's advanced usage and bash content, as well as Disk Management and file system knowledge

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.