Linux text editing commands (vi, VIM)

Source: Internet
Author: User
Tags line editor

Text Editor Categories:

Line editor: sed;

Full Screen Editor: Nano, VI (Visual Interface), Vim (vi improved)

One, Vim: Text editor: (Support ASCII code, Unicode code)

1. Vim Modal Editor:

Vim Pattern Classification:

Edit mode: (command mode); default mode;

Input mode:

Last-line mode: Built-in command interface


2. Vim [Options] [file:]

Options

+#: After opening the file, leave the cursor at the beginning of line #, and the default is the beginning of the first line;

+: Open file with cursor in tail line

+/pattern: After opening the file, the cursor is directly at the beginning of the first line that is matched to the PATTERN;


3. Mode conversion:

Edit mode Convert to Input mode method one: I key: Insert, enter at the cursor position

Edit mode to Input mode method two: A key: Append, at the location of the cursor input;

Edit mode to Input mode method three: 0 key: Opens a new line below the cursor;

Edit mode to Input mode method four: I key: At the beginning of the cursor where the input;

Edit mode to Input mode method five: A key: line at the end of the cursor input;

Edit mode to Input mode method six: O Key: Opens a new line above the cursor;


Input mode change to edit mode method one: Esc key:


Edit mode to last line mode method one:: Key (colon)


The last line mode is converted to edit mode method one: two times ESC key


Save exit:

ZZ: Save exit

: Wq: Save exit

: q! : Do not save exit

: x save and exit;

: W/path/to/somfile: Save as Somfile file;


4. Cursor Jump:

Jump between characters:

H Jump one character, J down jump, K up jump, L jump Right

#h, #j, #k, #l: Jumps to the corresponding direction # characters in turn

Jump between words:

W, the first word of the next word

E, the ending of the current or the next word;

B, the first word of the current or previous word;

#w, #e, #b: Jump to the corresponding direction in turn # words

Beginning line End Jump:

^: jumps to the first non-whitespace character at the beginning of a line

0:0; Jump to the beginning of the line (absolute beginning);

$: Jump to end of line

Inline Jump:

G: Jump to end of line

#G: Jump to the beginning of line #;

1G or GG: Jump to the first line;

Jump between sentences:

): Skip to the next sentence;

(: Jump to the previous sentence;

# (, #): Jump to the corresponding direction # sentence

Jump between Segments:

{: The previous paragraph fell;

}: the latter paragraph;

#}, #{: Jump to the corresponding direction # segment;


5, turn screen operation:

Ctrl+f: Turn a screen at the end of the file;

Ctrl+b: Turn one screen to the file header;

Ctrl+d: Half-screen to the tail of the file;

Ctrl+u: Turn half screen to file header;

Enter: Turn the line backward by row;


6. Vim Edit command:

Character editing:

X: Delete the character at which the cursor is located;

#x: Remove the # characters that are backward at the cursor

XP: Swap the character at the cursor and the position of the trailing character;

Replace command: Replace

R: Replace the character at the cursor, method: Enter R, followed by the character you want to replace;

Delete command: Delete will be put in buffer, delete something can be used to paste.

D: Delete command, can be combined with the cursor jump command , to achieve the scope of deletion; For example: D$,d^,dw,de,db,

#d: Delete # words, can be combined with the cursor jump command to use

DD: Delete a whole line;

#dd: Delete # whole line

Paste command (paste)

P: lowercase p; If the contents of the buffer are full lines, paste them below the current cursor, or paste them at the back of the cursor;

P: Uppercase P: The contents of the buffer if it is an entire line, paste it at the top of the line where the cursor is currently located, or paste it in front of the cursor;

Copy command (Yank):

Y: Copy, the working behavior is similar to the D command, can also be used in conjunction with the cursor jump command;

YY: Copy a whole line;

Y$,y^,y0,yw,ye,yb,

#yy: Copy # lines


Change command: change,c, like D command

Can be implemented when the delete operation, while converting to input mode;

C$,C^,C0,CW,CE,CB,CC, #cc


Visualization mode: (for Region selection)

V: selected by character;

V: Selected by row;

Collection Edit commands: D, C, y


Undo Action: Undo

U: Undo the previous operation;

#u: Undo the previous # operations;

Ctrl+r: Restore the previous undo operation;


Repeat the previous edit operation: (dot number)

.: Point number


Vim Tutorial: Vimtutor








Linux text editing commands (vi, VIM)

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.