VI usage Summary

Source: Internet
Author: User

VI is an important tool for Shell scripting and server settings.
There are many text editors in Linux, such as VI Emacs xemacs Joe E3 xedit kedit Pico. Each processor has its own features.

As we can see it both in front and back, We will summarize some other common function keys of the VI command line:

 

Move to the beginning of the current row ^
Move to the last character of this line: $
Move to the last row of the file: G
Move to the first line of this file: GG is equivalent to 1g
N <enter>: N is a number, and the cursor moves down n rows
/Word: Start from the cursor and look down for a string named Word
? Word: Search for the word string from the cursor
YY: copy the row where the cursor is located
Nyy: copy the N rows down the cursor
Tolower (P): paste the copied data to the next line of the cursor

Toupper
(P) is the last line pasted on the cursor
U: Restore the previous operation
[CTRL] + R: redo the previous operation

File restoration and temporary storage:
VI has the "recoverable" function. When editing a temporary file, a file with the extension filename. SWP can be recovered.

Vim's additional functions:
Currently, most versions use Vim to replace VI. If VI is used, you can see that the row number of the current cursor is displayed in the lower right corner of the screen, it indicates that your VI has been changed by VIM.

 

[Samson @ yygy] $ alias
Alias L. = 'LS-D. * -- color = auto'
Alias LL = 'LS-l -- color = auto'
Alias ls = 'ls -- color = auto'
Alias Vi = 'vim'
Alias which = 'Alias |/usr/bin/which -- tty-only -- read-alias -- show-dot -- show-tilde'

Block Selection: the previous operations are based on the unit of action. What if you want to solve the block range problem?
When the V, V, or Ctrl + V Key is pressed, the reverse white will start when the cursor is moved,
V: select a character. The cursor is reversed.
V: Select rows. The rows that the cursor passes are reversed.
CTRL + V: block selection. You can select data in a rectangle.
Y: copy the anti-whitelist
D: Delete the whitelist.

Multi-file Editing: Vim filename1 filename2
: N: edit the next file
: N: edit the previous file
: Files: Lists All files found by VIM.

Multi-Window Function:
When you want to compare a large file or two files, you need to use
In command mode, enter: SP [filename] filename. If you want to open another file in a new window, add the file name.
Buttons in multiple Windows:
CTRL + WJ: move the cursor to the window below
CTRL + WK: move the cursor over the window
CTRL + WQ: End Window

Vim will take the initiative to record the behavior that has been done. The file that records the action is ~ /. Viminfo
Vim operating environment: it is generally stored in the/etc/vimrc file. We recommend that you do not modify it to modify it ~ /. Vimrc File

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.