Linux command explanation-text editor

Source: Internet
Author: User
Tags delete key

1. VI Editor

Three modes:

Command mode

VI filename

(1.) Positioning:

H: Move one character to the left J: Move down one character K: move one character up L: Move right one character $: moves to end of line 0: moves to the beginning of lines Enter: Move to the start of the row H: Move to the top of the screen M: Move to the screen terminal L: Move to the bottom of the screen

G: To the last line of the file 1G: to the first line of the file NG: to the nth line of the file, equivalent to: n

(2.) Delete command:

X: Delete the character of the cursor, delete it backwards, equivalent to the BACKSPACE key X: Delete the character in front of the cursor, equivalent to the DELETE key DD: Delete the line where the cursor is located DG: Delete the line to the end of the cursor D: Delete the cursor at the bottom of the line: n1,n2d Delete section n1- N2 the contents of the line

(3.) Copy command:

YY: Copy current line equal to Y nyy,ny copy current line following n line p: Paste

(4.) Replace and cancel

R: Replace the character at the cursor (single substitution) r: Replace the character from the cursor, press ESC to exit, end replace (continuous substitution) s: replace the character at the cursor, and enter the text input method (delete the current character and enter insert mode) s: Replace the full line of the cursor, press ESC to end (delete the entire row, and go into insert mode) U: Cancel the previous action, Cancel to the point where the file was last opened, not the place to save. Press Ctr+r to cancel U: Cancels all operations on the current line

(5.) Save and exit

: W Save: W newfile Save as: Wq Save exit: Q Exit ZZ exit: q! Force exit: X Save exit: x! Force Save exit

(6.) Search and replace

Slash search:/string n search down n Search question mark search:? String substitution::%s/old/new/g All find replace search to delete all::%s/old//g

(7) Other operations

: R FileName reads the file into another file:! Command not to exit VI, to perform other operations to open more than one file: Vi–o file1 file2 (Up/Down window) Press CTR+WW two window switch vi–o file1 file2 about two windows open file

Insert mode

Input I: Insert before cursor I: Insert a at the beginning of the cursor: Insert a: At the end of the line insert O: Insert a new line under the cursor o: Insert a line on the cursor press ESC to enter command mode

Edit mode

Press Colon to enter edit mode from command mode and press ENTER to enter command mode again. Eg:setnu

When exiting VI: Command mode, press ZZ to exit: Q

Set line number: Set Nu Cancel line number: Set Nonu config file: Home directory VI vimc write set Nu

VI A text editor, when two users edit a file at the same time, with the last user's save as the subject.

Linux command explanation-text editor

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.