Common commands of the text editor vi and Common commands of the vi in linux

Source: Internet
Author: User

Common commands of the text editor vi and Common commands of the vi in linux
I. Paging

Ctrl + u flip up half page

Ctrl + f Turn up one page

Ctrl + d flip down half page

Ctrl + B flip down one page

Ii. move the cursor

0: move the cursor to the beginning of the current row

$: Move the cursor to the end of the current row

Iii. Common insert and delete commands

I: insert in front of the current cursor, move the text behind the cursor to the back

Dd: Delete the row where the cursor is located.

Yy: copy the content of the current row to the clipboard.

P: paste the content in the clipboard after the current cursor position

P: paste the content in the clipboard before the current cursor position

S: Starting from the current cursor position, replace the specified number of characters with the input text

S: delete a specified number of rows and replace them with the input text

Do: Delete to the beginning of a row

D $: Delete to the end of the row

Iv. vi search, save, and exit

Press u to cancel the last operation. You can perform the operation multiple times, similar to canceling the operation.

Press U to cancel all edits on the current row. : W -- save the current file

: Wq -- save disk to exit (same as command: x)

: Q -- exit directly. If modified, a message indicating whether to save the modification is displayed.

: Q! -- Exit directly without saving

5. Open a new file or read other file content

In the current vi Editor, execute the last line command in the form of ": e new file" to edit the new file.

In the current vi Editor, execute the last line command in the form of ": r other files" to read the contents of other files and copy them to the position of the current cursor.

In the current vi Editor, Run ": r! Command "form of Moxing mode, you can paste the output of other commands to the position of the text file cursor.

Run the "set number" command in the last line mode to display the row number. Run "set nonu" to undisplay the row number.

Vi. vim editor's useful parameters

Vim-o file1 file2; the two files are opened at the same time and displayed up and down. use ctrl + w to switch files.

Vim-O file1 file2; the two files are opened at the same time and displayed on the left and right. use ctrl + ww to switch the 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.