Linux vi command details: on-screen text editor Vi (1)

Source: Internet
Author: User

This chapter describes linux vi commands in detail. The text editor is the most commonly used tool in all computer systems. When using a computer, users often need to create their own files. Whether it is a common text file, a data file, or a source program file, these jobs cannot be separated from the linux vi command.

Linux provides a complete family of editors, such as Ed, Ex, Vi, and Emacs. They can be divided into two categories by function: Row editor Ed and Ex) full Screen Editor Vi, Emacs ). The row editor can operate only one row at a time, which is inconvenient to use. The full-screen editor can edit the entire screen, and the files edited by the user are directly displayed on the screen. The modification results can be immediately displayed, avoiding the unintuitive operations of row editing, it is easy for users to learn and use and has powerful functions.

The linux vi command is the first full-screen interactive editing program in the Linux system. It has been favored by many users since its birth. It has been a main text editing tool for decades, it is obvious that its vitality is strong, and its powerful vitality is brought about by its powerful functions.

This chapter describes how to use linux vi commands to create, edit, display, and process files. Note: The uppercase letters in the text are [shift] keys + combinations of corresponding lowercase letters)

Introduction to linux vi commands

The linux vi command is short for "Visual interface", and its position on Linux is as if the Edit Program is on DOS. It can perform output, delete, search, replace, block operations, and many other text operations, and users can customize it according to their own needs, which is not available in other editing programs.

The linux vi command is not a typographical program. Unlike Word or WPS, it can orchestrate fonts, formats, paragraphs, and other attributes. It is just a text editing program.

Linux vi commands have no menus, only commands, and many commands. Vi has three basic working modes: command line mode, text input mode, and last line mode.

Command Line Mode

At any time, no matter what mode the user is in, just press the key to enable the linux vi command line mode. In the shell environment prompt $), enter the linux vi command to start, the editor is also in this mode.

In this mode, you can enter various valid linux vi commands to manage your own documents. In this case, any character entered on the keyboard is interpreted as an editing command. If the entered character is a valid linux vi command, then, the linux vi command completes the corresponding action after receiving the USER command. Note that the entered command is not displayed on the screen. If the entered character is not a valid command of Vi, Vi will ring an alarm.

Text input mode

In command mode, Enter command I, attach command a, open command o, modify command c, replace command r, or replace command s to enter the text input mode. In this mode, any character entered by the user is saved as the file content by Vi and displayed on the screen. During text input, if you want to return to command mode, press the key.

Last Row Mode

The last row mode is also called the ex escape mode.

The functions of the linux vi command and the Ex editor are the same. The main difference between the two is the user interface. In Vi, a command is usually a single key, such as I, a, o, etc. In Ex, the command is the text line ending with the Enter key. The linux vi command has a special "escape" command to access many line-oriented Ex commands. In command mode, you can press the ":" key to enter the last line mode. At this time, the linux vi command will display a ": as the last line prompt, waiting for the user to enter the command. Most file management commands are executed in this mode, for example, writing the content of the editing buffer to a file is moderate ). After the last line of command execution is complete, the linux vi command automatically returns to the command mode. For example:

: 1, $ s/A/a/g

Replace uppercase A with lowercase a from the first line to the end of the file.

If you have changed your mind when entering the command in the last line mode, press the button or use the return key to delete all input commands, and then press the return key, then, the linux vi command is returned to the command mode.

To switch from command mode to edit mode, TYPE command a or I. To return from text mode, Press Esc. In command mode, enter ":" to switch to the last line mode, and then enter the command.


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.