In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "what is the function of Linux's vi command". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Linux common commands vi command is the most general full-screen plain text editor in UNIX operating system and UNIX-like operating system. The vi editor in Linux is called vim, which is an enhanced version of vi (vi Improved), is fully compatible with the vi editor, and implements many enhancements.
Vi's powerful plain text editor
It is added that the vi editor supports editing mode and command mode, the editing function of the text can be completed in the editing mode, and the operation command of the file can be completed in the command mode. If you want to use the vi editor correctly, you must skillfully master the switch between the two modes. By default, you automatically enter command mode when you open the vi editor. Switch from editing mode to command mode using the "esc" key, and from command mode to editing mode using the "A", "a", "O", "o", "I", "I" keys.
The vi editor provides a wealth of built-in commands, some of which can be done using keyboard keys, while others need to be entered with a colon. Common built-in commands are as follows:
Ctrl+u: flip half the screen first to the file; Ctrl+d: flip half the screen to the end of the file; Ctrl+f: flip the screen to the end of the file; Ctrl+b: flip the first screen to the file; Esc: switch from edit mode to command mode; ZZ: exit after saving changes made by the current file in command mode: line number: cursor jumps to the beginning of the specified line;: $: the cursor jumps to the beginning of the last line X or X: delete a character, x after the cursor, and X delete before the cursor; D: delete all characters from the current cursor to the end of the line where the cursor is located; dd: delete the forward line contents of the cursor line; ndd: delete the current line and subsequent n-1 lines; nyy: save the contents of the current line and its next n lines to the register? In, among them? For a letter, n is a number; p: paste text operation, which is used to paste the contents of the cache area below the current cursor position; P: paste text operation, used to paste the contents of the cache area above the current cursor location / string: text search operation, which is used to find the contents of the specified string at the end of the file starting from the current cursor position, and the found string will be highlighted. String: text search operation, which is used to find the contents of the specified string from the current cursor position to the head of the file, and the string to be found will be highlighted; a meme bscompFhand T: replace the text operation for the F string to T string between line an and line b. Where "s /" indicates a replacement operation; a: add text after the current character; A: add text at the end of the line; I: insert text before the current character; I: insert text before the current line; o: insert a blank line after the current line; O: insert a blank line before the current line;: wq: perform a save exit operation in command mode;: W: perform a save operation in command mode;: W! : in command mode, perform a forced save operation;: Q: in command mode, perform an exit vi operation;: Q! : in command mode, perform a forced exit vi operation;: e file name: in command mode, open and edit a file with the specified name;: n: in command mode, if you open multiple files at the same time, continue to edit the next file;: F: in command mode, it is used to display the current file name, the line number of the cursor, and the display scale : set number: in command mode, for displaying line numbers at the leftmost end;: set nonumber: in command mode, for not displaying line numbers at the leftmost end; syntax vi (option) (parameter) option +: displays text content from the line where the line number is specified;-b: opens the file in binary mode for editing binaries and executables -c: after completing the first file editing task, execute the given instructions;-d: open the file in diff mode, and when multiple files are edited, show the file differences;-l: use lisp mode to open "lisp" and "showmatch";-m: cancel the write file function and reset the "write" option;-M: turn off the modification function;-n: do not use the cache function -o: specify to open a specified number of files at the same time;-R: open files read-only;-s: quiet mode, any error messages for unrealistic instructions. Parameter file list: specifies the list of files to edit. Multiple files are separated by spaces.
The knowledge extension vi editor works in three ways: command mode, input mode and ex escape mode. The conversion between these three working modes can be carried out through the corresponding command or operation.
Command mode
Enter the command vi at the Shell prompt, enter the vi editor, and be in vi command mode. At this point, any characters entered from the keyboard are interpreted as editing commands, for example, a (append) for additional commands, I (insert) for insert commands, x for delete character commands, and so on. If the character entered is not a legitimate command of vi, the machine emits an "alarm sound" and the cursor does not move. In addition, the characters entered in the command mode (that is, the vi command) are not displayed on the screen. For example, entering I does not change on the screen, but by executing the I command, the editor works differently: from command mode to input mode.
Input mode
The input mode can be entered from the command mode by entering the vi insert command (I), additional command (a), open command (o), replace command (s), modify command (c), or replace command (r). In input mode, all characters entered from the keyboard are inserted into the buffer being edited as the body of the file. After entering the input mode, all the visible characters entered are displayed on the screen, while the editing command no longer works and appears only as ordinary letters. For example, enter the letter I in command mode, enter input mode, and then enter I to add a letter I at the corresponding cursor on the screen.
The way to return from input mode to command mode is to press the Esc key. If you are already in command mode, pressing the Esc key will beep. To ensure that the vi command that the user wants to execute is entered in command mode, press the ESC key a few more times and enter the command after hearing the beep.
Ex escape mode
The functions of the vi and ex editors are the same, with the main difference being the user interface. In vi, a command is usually a single letter, such as a _ line _ x _ r, and so on. In ex, a command is a command line that ends with the Enter; key. Vi has a special "escape" command that accesses many line-oriented ex commands. To use ex escape, enter a colon (:). As an ex command prompt, the colon appears on the status line (usually at the bottom of the screen). Press the interrupt key (usually the Del key) to terminate the command that is being executed. Most file management commands are executed in ex escape mode (for example, read the file and write the contents of the edit buffer to the file medium). After the escape command is executed, it automatically returns to the command mode. For example:
1According to the enter key, replace all uppercase I with lowercase I from the first line of the file to the end of the file ($).
This is the end of the content of "what is the purpose of Linux's vi command". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.