Using the VIM Editor:

Source: Internet
Author: User

Using the VIM Editor:
VI is working in the character terminal environment of the full-screen editor, by the command to achieve the corresponding editing and operation functions, vi Editor can use three different modes of operation:

Command mode: Start the VI Editor by default into command command mode, the main completion of the mode such as cursor movement, string lookup, and delete copy and paste, file content and other related operations;
Input mode: This mode starts the main operation is to input the contents of the file, you can modify the text file body or add new content, in the input mode, the last line of the VI editor will appear "--insert--" Status prompt information;
The last line mode, the mode can set the VI editor environment, save the file, exit the editor, as well as the contents of the file to find, replace, and so on, in the final line mode, vi Editor will appear in the end of the colon ":" Prompt message;

Mode switch:
In command mode, the A,i,o is used to quickly switch to the input mode while determining the way and location of the insertion point in order to enter the file contents. When you need to return to command mode, press ESC,

A: Insert the contents of the file after the current cursor position;
A: Insert the content at the end of the line where the cursor is located;
I: Insert content before the current cursor position;
I: Insert content at the beginning of the line at the cursor;
o: Insert a new line after the cursor line;
O: Insert a new line in front of the line where the cursor is located;

page Shift: Ctrl+f key down a full page of content
Ctrl+b keys to turn up a full page of content
in-line quick Jump : Press the Home key or the "^" key, the number 0 jumps the cursor quickly to the first line of the file content
Press the END key or the "$" key to quickly jump the cursor to the end of the bank
Quick Jump between lines: Use the key command 1G or GG to jump to the first line of the file content
Use the key command G to jump to the last line of the file
Use the key command #g to jump to the # # line in the file (where "#" is replaced with a specific number)
Display line number:: Set Nu
To suppress line numbers: set Nonu

Copy Paste and delete:
Use the X key or the DEL key to delete a single character at the cursor;
Use the case command DD to delete the current cursor line, using #dd can delete the beginning of the cursor from the line of content;
Use the key command d^ to delete all characters before the current cursor to the beginning of the line;
Use the key command d$ to delete all characters at the end of the line at the current cursor;

Copy operation:
Use the key command yy to copy the contents of the current entire line to the Clipboard, using the #yy form to copy the # line from the cursor to the beginning
Paste operation: P key

Find content:
In command mode, press the "/" key to enter the specified string and press "?" The key is searched forward, press "n" key to move to the next search result;

Undo Edit and Save exit
When editing the file, sometimes there are some mistakes in the editing operation to undo, you can Press "U", "U" key,
The "U" key command is used to cancel the last operation;
The "U" key command cancels all edits made to the current line
You can press the ZZ command when you want to save the contents of the current bid and exit the VI editor

Basic operations in the last-line operation:
: W Exit
: Wq Save Exit
: Wq/root/newfile refers to saving the currently edited file to/root under the file name NewFile
: q! Do not save forced exits
: X Save exit

Open a new file or read the contents of another file:
1, open a new file for editing, in the current VI editor, execute ": E (New file)" As the form of the last line command can edit the new file;
2, execute ": R other File" in the form of the last line command can read into the contents of other files, and copy it to the current cursor location,
3. Replace file contents ": [Replace Range] Sub/old content/new content [/g]"
#%: Find and replace throughout the file content,
#n, M: Find and Replace in file contents within a specified number of lines
The #最末尾的 "/g" section is also optional, which means that all matching results for each row in the replacement range are replaced, and the first matching result in each row is replaced when the "/g" is omitted.

Using the VIM Editor:

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.