VI Text Editor

Source: Internet
Author: User

VI command

the VI command is the most versatile full-screen plain text editor in Unix operating systems and UNIX-like operating systems. The VI editor in Linux is also called Vim, which is the enhanced version of VI (VI improved), fully compatible with the VI editor, and implements a number of enhancements.

VI Editor support editing mode and command mode, editing mode can complete the editing of the text, command mode can complete the operation of the command, the correct use of the VI editor must master two modes of switching. By default, the VI editor is opened and automatically enters command mode. Switch from edit mode to command mode use "ESC" key to switch from command mode to edit mode using "a", "a", "O", "O", "I", "I" Keys.

The VI Editor provides a rich set of built-in commands, some built-in commands to use the keyboard key combinations, and some built-in commands that require a colon ":" to start typing. Common built-in commands are:

Ctrl+u: To file the first half screen;  ctrl+d: Half screen to the end of the file;  ctrl+f: Flip one screen to the end of the file;  ctrl+b: Flip one screen to the top of the file;  esc: switch from edit mode to command mode;  ZZ: Save the changes made in the current file in command mode and exit vi; : line number: Cursor jumps to the beginning of the specified line;  :$: The cursor jumps to the beginning of the last line;  x or x: Deletes a character, x deletes the cursor, and x deletes the;  before the cursor D: Delete all characters from the current cursor to the end of the line at which the cursor is located;  DD: Delete the line contents of the cursor,  NDD: Delete the current line and its subsequent n-1 rows;  nyy: Saves the contents of the current row and its next n rows to the register? In, where? is a letter, n is a number;  p: Pastes the text action to paste the contents of the buffer below the current cursor position;  p: Pastes the text action to paste the contents of the buffer above the current cursor position;  /string: Text lookup operation, Used to find the contents of the specified string from the current cursor position to the end of the file, and the found string is highlighted;   Name: A text lookup operation to find the contents of the specified string from the current cursor position to the head of the file, the found string is highlighted, and the  a,bs/f/t: replaces the text action, which is used to change the F string to a T string between lines A and B. Where "s/" represents a substitution operation;  a: Adds text after the current character;  a: Adds text at the end of the line;  i: Inserts text in the current word match either;  i: Inserts text at the beginning;  o: Inserts a blank line after the current row;  o: Insert a blank line in front of the current line;  :WQ: in command mode, perform a save operation;  :w: in command mode, perform a disk operation;  :w! : In command mode, execute the Force disk operation;  :Q: in command mode, perform exit VI operation;  :q! : In command mode, execute force quit VI operation;  :e file name: In command mode, open and edit the file of the specified name;  :n: in command mode, if you open multiple files at the same time, continue editing the next file;  :f: in command mode, Used to display the current file name, the line number of the line where the cursor is located, and the display scale;  :set number: in command mode, to display line numbers at the leftmost end;  :set nonuMber: In command mode, the line number is not displayed on the leftmost side; 

Span style= "font-size:20px;font-family: ' Blackbody ', Simhei;background-color:rgb (255,255,255); line-height:18px;" > syntax:   VI (option) (parameter)
options:

+< line;: Begins the text content from the line of the specified line number;  -b: Opens the file in binary mode for editing binaries and executables;  - c< instruction;: After the completion of the first file editing task, execute the given instruction;  -d: Open the file in diff mode, and when multiple files are edited, display the file differences section;  -l: Use Lisp mode to open "Lisp" and " Showmatch ";  -m: Cancel the Write file function, reset the" write "option,  -m: Turn off the modification function;  -n: The number of files; -o< not functional cache;: Specifies that the specified number of files be opened at the same time;  -r: Open File as read-only;  -s: Quiet mode, no error message for realistic instruction. 

parameter : file list: Specifies the list of files to edit. Separate multiple files with spaces.

  The &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;VI editor has three modes of operation: Command mode, input mode, and ex escape mode. You can convert between these three modes of work by the appropriate command or operation. Command mode at the shell prompt, enter command VI, enter the VI editor, and in the VI command mode. At this point, any characters entered from the keyboard are interpreted as an edit command, for example, a (append) represents an additional command, I (insert) represents the Insert command, X is the delete character command, and so on. If the input character is not a legal command of VI, the machine emits an "alarm sound" and the cursor does not move. In addition, the character entered in the command mode (that is, the VI command) is not displayed on the screen, for example, input I, there is no change on the screen, but by executing the i command, the editor works in a different way: from the command mode to input mode. The input mode can be entered by entering the command (i), attaching the command (a), opening the command (o), replacing the command (s), modifying the command (c), or replacing the command (R). In the input mode, all characters entered from the keyboard are inserted into the buffer being edited and are treated as the body of the file. After entering the input mode, the input visible characters are displayed on the screen, and the edit command no longer works, only as ordinary letters appear. For example, enter the letter I in the command mode, enter the input mode, and then enter I to add a letter I at the corresponding cursor on the screen. The way the input is returned to the command mode is to press the ESC key. If it is already in the command mode, then pressing the ESC key will emit a "beep" sound. In order to ensure that the user wants to execute the VI command is entered in the command mode, it is advisable to press the ESC key more than one, hear the beep and then enter the command.

  The functionality of the         ex escape Method VI and the EX editor is the same, and the main difference between the two is the user interface. In VI, commands are usually a single letter, such as A,x,r. In ex, the command is the command line with enter and the key to end. VI has a dedicated "escape" command to access many of the line-oriented ex commands. To use the ex escape method, you can enter a colon (:). As an ex command prompt, the colon appears in the status line (usually on the bottom line of the screen). Press the interrupt key (usually the DEL key) to terminate the command being executed. Most file management commands are executed in ex-escape mode (for example, reading a file, writing the contents of the edit buffer to a file medium). After the escape command executes, it automatically returns to the command mode.

          For example: :1, $s/i/i/g press ENTER      

from the first line of the file to the end of the file ( $) Replace uppercase I with all lowercase i. The VI Editor's conversion between the three modes of operation.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/74/58/wKiom1YaVhGwKsySAAEWK1p9u6c680.jpg "title=" vi.jpg "alt=" Wkiom1yavhgwksysaaewk1p9u6c680.jpg "/>



This article is from the "Wind Technology blog" blog, please be sure to keep this source http://chenfmt.blog.51cto.com/10547344/1701902

VI Text Editor

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.