Laruence's linux private food-vim editor study notes

Source: Internet
Author: User
Why use the vim editor: all UnixLike systems have built-in vi file editors. Other file editors do not necessarily exist; many editing interfaces of some software call vi (for example, crontab, mongodo, edquota and other commands that will be discussed in the future). vim has programs...
Why use the vim editor:
All Unix Like systems have built-in vi file editors. Other file editors may not exist;
Many software editing interfaces call vi (for example, crontab, mongodo, edquota, and so on ).
Command );
Vim has the ability to edit programs. it can actively identify the correctness of the syntax by Font color to facilitate program design;
Because the program is simple, the editing speed is quite fast.
Www.2cto.com
Summary of vim editor usage:
General mode:
Vi aa: If the aa document exists



If the aa document does not exist, the system will prompt NEW



I: insert mode (insert starts at the position where the cursor flashes)
S: rewrite the letter where the cursor is located
O: insert another row
Press a number and then click enter to jump to n rows under the row where the cursor is located (for example, 10)
Ctrl + f: Page Up (equal to pageup)
Ctrl + B: pagedown)
Yy: Copy the row where the cursor is located
5yy: Copy the row where the cursor is located and the following five rows
X: cut the character of the cursor (content at the current position)
Dd: cut the row where the cursor is located
5dd: cut the five rows, including the row where the cursor is located and the four rows below it
P: click p once, and paste it in the next or next line at the blinking position.
5 p: Paste the copied content five times
H: left button
J: next row
K: The last row.
L: Right-click
W: Move words to the first letter of the next list
E: move a word to the end of the next word.
U: undo once
Ctrl + r: the upper, lower, and lower keys are usually used to restore to the latest status.
Visualization mode:
Press ctrl + v: The Visible block. move the cursor up or down to form a drawing.
Click y to copy the selected content, and then click d to delete the selected content.
 
Command line mode:
: W: Save (save only here, but do not exit, wq! To force save and exit, same as x)
: E! : Restore the archive to the oldest state (the last time w was saved)
: Set nu: list row numbers
: Set nonu: unlists row numbers.
: 1: The cursor returns to the first line.
: 134: Move the cursor to row 134
: $: Move the cursor to the last line
:/Word: Search for the next word character (string) after the cursor (then Click n to search for the word, and the entire document will be searched)
:? Word: Search for the previous word character (string) before the cursor (then Click n to search up, and the entire document will be searched)
Www.2cto.com
Replace:
: 1, 5S/o/A/g: replace the small o from the first row to the fifth row with A, g indicates all replace
: S/o/X/gc: Enter the replace interactive mode. The small o in lines 4 to 7 asks whether to replace one by one. five options are available: ynaql, y indicates yes, n indicates no, a indicates all, q indicates quit, and l indicates line (only this line is replaced)
Save:
: 1, 10 w pass10: Save 1 to 10 behavior pass10
: W passchang: Save as passchang document
: R pass10: add the content of pass10 when editing the current file.
 
About Double-Open (multi-file editing ):
In command line mode, enter sp/etc/passwd to edit the passwd file, which is half of the screen of the original file;

Press ctrl + w and press j to jump to the following file for editing.
Press ctrl + w, and then press k to jump to the file above for editing.
The two switches above are the same as ctrl + w. double-click the two switches to redirect back and forth.
 

Www.2cto.com
You can edit multiple documents at the same time:
Vim passwd: open three windows to edit the passwd file. in command line mode, enter: n to edit the next file and: N to edit the previous file.
Vim passwd man. config: both the passwd and man. config files are edited. in command line mode, enter: n to edit the next file and: N to edit the previous file.
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.