Linux tutorial-full screen text editor

Source: Internet
Author: User
Article title: Linux tutorial-full-screen text editor. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
This chapter describes the most common text editor Vi on Linux. 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 tasks cannot be separated from the editor.
  
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, 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.
  
Vi is the first full-screen interactive editing program in Linux. it has been favored by many users since its birth. it is still the main text editing tool used by people 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 Vi to create, edit, display, and process files. (Note: the uppercase letters in the text are [shift] Keys + combinations of corresponding lower-case letters)
  
Vi introduction
  
Vi 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.
  
Vi 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.
  
Vi has no menu, 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 bring Vi to the command line mode. in the shell environment (the prompt is $), enter the command to start Vi, the editor is also in this mode.
  
In this mode, you can enter various valid Vi commands to manage your own documents. At this time, any character entered on the keyboard is interpreted as an editing command. if the entered character is a valid Vi command, Vi 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 Vi and Ex editors have the same functions. The main difference between them 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. Vi has a dedicated "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, Vi 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 in the editing buffer to a file is moderate ). After the last-line command is executed, Vi 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, you can press
Or use the return key to delete all input commands, and then press the return key to return Vi to the command mode.
  
The conversion between the three working modes of the Vi editor is 11-1.
  
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.
  
From Turbolinux
  
  
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.