Brief Introduction to Linux Vivi command operations

Source: Internet
Author: User

I will introduce the Linux vi command in detail, and then introduce the Linux vi command in detail. I hope it will be useful to you. The Fedora Core Linux is developed in a community-supported way, and the development team of Red Hat Linux will continue to participate in the development of this release.

Text insertion

In command mode, any character entered by the user is interpreted and executed by the Linux vi command. If the user wants to treat the entered character as text content, first, switch the operating mode of the Linux vi command from the command mode to the text input mode. The following command is used for switching. Insert) command Linux vi command provides two Insert commands: I and I.

I command

Insert text starts before the cursor position and can be used during the Insert Process Key deletion error input. At this time, the Linux vi command is inserted, and the "-- INSERT --" INSERT) "is displayed at the bottom of the screen. There is a file being edited, as shown below: Welcome to vi world! Come on!
The cursor is located at the first "!" Insert This is an example!
Run the I command and enter the corresponding text. The screen is displayed as follows:
Welcome to vi world This is an example !! Come on!
In this example, we can see that the cursor is originally in the first "!" But it is inserted before the cursor position, so this "!" It is squeezed into the new inserted text.

I command

The Linux vi command moves Vi on the screen provides three commands about moving the cursor across the screen without scrolling the file itself. They are H, M, and L commands.

H command

This command moves the cursor to the top left corner of the first line of the screen), that is, the first line of the current screen, rather than the first line of the entire file. You can use this command to quickly move the cursor to the top of the screen. If n is added before the H command, move the cursor to the beginning of the n line.
The screen displays the following content:
# Include
Main)
{Int k;
For k = 0; k <3; k ++) add );}
Add)
{Static int x = 0;
X ++;
Printf "x = % d \ n", x );
"Example. c" [New File]
In Linux vi command mode, enter the 4 H command, and move the cursor to the letter f starting with ". It is worth mentioning that the command dH will delete all content from the current row of the cursor to the first line of the displayed screen.

M command

This command moves the cursor to the beginning of the line in the middle of the display file. That is, if the current screen is full, it will be moved to the middle line of the screen; if it is not full, it will be moved to the middle line of the lines of the text. This command can be used to quickly move the cursor from any position on the screen to the beginning of the line in the middle of the screen display file. For example, when the above screen is displayed, no matter where the cursor is on the screen), in Linux vi command mode, after the M command is input, the cursor will be moved to the letter a in the add line. It is also worth mentioning that using the command dM will delete all content from the current row of the cursor to the middle row of the displayed file on the screen.

L command

When the content displayed in the file exceeds one screen, this command moves the cursor to the beginning of the line at the bottom of the screen. When the content displayed in the file is insufficient, this command moves the cursor to the beginning of the last line of the file. This command can be used to quickly and accurately move the cursor to the bottom of the screen or the last line of the file. If n is added before the L command, move the cursor to the beginning of the n line starting from the bottom of the screen. For example, when the above screen is displayed, no matter where the cursor is on the screen), in command mode, after entering the 3L command, the cursor will be moved to the letter x in the row x ++.
It is also worth mentioning that the command dL will delete all content from the current row of the cursor to the bottom line of the screen.

Moving the cursor by words first introduces the concept of "word" in Linux vi commands. In Linux vi commands, "word" has two meanings. A word in a broad sense can be any content between two spaces.

In the file example. row 4th in c: {int k; it has only 2 characters. One is {int, and the other is k. The other word in Vi is narrow, in this sense, English words, punctuation marks, and non-letter characters such!, @, #, $, %, ^, &, *,),-, +, {,}, [,], ~, |, \, <,>,/, Etc.) are considered as a word. Therefore, the above line contains the words {, int, k, and.
In Linux vi commands, uppercase commands are generally used to treat words in a broad sense, while lowercase commands are used to treat words in a narrow sense.

  1. Linux vi command replacement instructions
  2. Tips for adding a row number to a linux vi command line
  3. Practical Tips: linux vi command shortcut key set
  4. Linux vi command details and usage tips
  5. Linux vi command details: on-screen text editor Vi

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.