Use the VIM editor in centos

Source: Internet
Author: User
1. start and exit the VI editor # vifile1 creates a new text file named file1 ~~ : Q! Exit in last line mode 2. text operations ~ : E! File1: edit the new file in the current file: r/etc/passwd to implement the file reading function: wq keep and exit: q! Force exit 3. move the cursor 3.1. move the cursor (in command mode) h -- move the cursor to the left l -- move the cursor to the right k -- move the cursor up j -- move the cursor down 3.2, flip the page (in command mode) 1. start and exit the VI editor
# Vi file1 create a text file named file1
~
~
: Q! Exit in last line mode
2. text operations
~
: E! File1: edit a new file under the current file
: R/etc/passwd for file reading
: Wq maintained and exited
: Q! Force exit
3. move the cursor 3.1 Move the cursor (in command mode)
H -- move the cursor to the left
L -- move the cursor to the right
K -- move the cursor up
J -- move the cursor down 3.2 Page Flip (in command mode)
Ctril + F flip the whole page forward
Ctril + B flip the whole page
Ctril + U front half page
Ctril + D flip back half page 3.3. in-line quick jump (in command mode)
^ Jump the cursor to the first line of the line quickly
$ Quickly jump the cursor to the end of the line
Nw quickly jump the cursor to the first letter of the last n words at the position of the current cursor
Nb quickly jumps the cursor to the first n words of the current cursor position
Nc redirects the cursor to the last n words of the current cursor. 3.4 fast jump between file experts
: Set nu display row number
: Set nonu undisplay row number
4. edit operations 4.1 enter the input mode (in command mode)
I enter the insert status at the current cursor
Cw deletes the characters at the end of the word where the current cursor is located and enters the insert status.
C $ delete the characters from the current cursor to the end of the line and enter the insert status
C ^ delete the character from the current cursor to the end of the line and enter the insert status 4.2 Input mode operations
Move the cursor using the up, down, left, and right arrow keys
Home and End: Move the cursor to the beginning and End of the line
Page Up and Page Down
Backspace delete the character on the left of the cursor
Delect deletes the character at the cursor position 4.3 Delete operation
X delete a single character at the cursor
Dd deletes the row where the cursor is located.
Dw deletes all characters from the current character to the end of the word
D $ delete all characters from the current character to the end of the line
D ^ delete all characters from the current character to the beginning of the line
J. merge the content of the current row and the next row. 4.4 undo
U cancels the last operation
U cancels all operations performed on the current row
Ctrl + R restore the undo operation using the u command 4.5 copy operation
Yy copies the content of the current positive line to the VI buffer
Yw copies the content of the current cursor to the end of the word to the VI buffer.
Y $ copy the content from the current cursor to the end of the row to the VI buffer
Y ^ copy the current cursor to the beginning of the line to the VI buffer
: M, ny copy the text between Row m and row n to the VI buffer 4.6 paste
P reads the VI buffer to the current cursor position
5. search and replace operations 5.1 Top-down search operations
:/Word searches for strings matching word
N. find the next matched string.
N reverse lookup the next matched string 5.2 bottom-up search operations
? Word searches for strings matching word
N. find the next matched string.
N reverse lookup the next matched string 5.3 replacement
: S/old/new replace the first character of the current line. old is the character new.
: S/old/new/g replace all characters of the current row with old as the character new
: M, ns/old/new/g replace all the characters from the current row number m to the row number n old with the character new
: % S/old/new/g replace all characters of the entire text. old is the character new 5.7 use the replacement confirmation function
: S/old/new/c replace the first character of the current line with "old" and prompt the user to confirm the operation
: S/old/new/gc replace all characters of the current row. the old character is the new character and prompts the user to confirm the operation.
: M, ns/old/new/gc replace all the characters from the current row number m to the row number n old with the character new and prompt the user to confirm the operation
: % S/old/new/gc replace all characters of the entire text. the old character is the new character and prompts the user to confirm the operation.
6. online help of VI editor
6.1 install other software packages of the VI editor.
Place the 2nd installation discs of RHEL4 into the disc drive of the host, and run the following command with the administrator root permission to install the additional software package of the VI program.
# Mount/dev/cdrom/media/cdrom
# Cd/media/cdrom/RedHat/RPMS/
# Rpm-ivh vim-common-6.3.035-3.i386.rpm vim-enhanced-6.3.035-3.i386.rpm
# Cd ~
# Umount/media/cdrom/dev/cdrom
: Help to view VI help information

This article is from the blog of "The Linux open source technology blog", please be sure to keep this source http://dreamfire.blog.51cto.com/418026/159336


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.