linux instruction --vi instruction

1. The basic concept of vi
  Basically vi can be divided into three states, namely command mode (command mode), insert mode (Insert mode) and bottom line mode (last line mode), the functions of each mode are as follows:
  1) Command line mode (command mode)
  controls the movement of the screen cursor, deletes characters, words or lines, moves and copies a section and enters Insert mode, or goes to last line mode.
  2) Insert mode (Insert mode)
  Only in Insert mode, text input can be done, press the "ESC" key to return to the command line mode.
  3) The bottom line mode (last line mode)
  saves the file or exits vi, and can also set the editing environment, such as searching for strings, listing line numbers...etc.

不过一般我们在使用时把vi简化成两个模式,就是将底行模式(last line mode)也算入命令行模式command mode)。

1. The basic concept of vi
  a) Enter vi
 After entering vi and file name in the system prompt symbol, enter the vi full-screen editing screen:
  $ vi myfile
  If this file does not exist before, it will be newly created. If the file already exists, there is no prompt.
  But there is one thing to pay special attention to, that is, after you enter vi, you are in "command mode (command mode)", you have to switch to "Insert mode (Insert mode)" to be able to enter text.
  b) Switch to insert mode (Insert mode) to edit the file Click the letter "i"
  in "command mode (command mode)" to enter "Insert mode (Insert mode)", then you can start typing text .
  c) Switch of Insert
  You are currently in "Insert mode", you can only enter text all the time, if you find that you have entered a wrong word! If you want to use the cursor keys to move back and delete the word, you must first press the "ESC" key to go to "command mode" and then delete the word.
  d) When text editing is finished, it is usually necessary to exit the editor. There are 4 cases to exit the editor: save and exit, normal exit, unsaved exit and forced exit.
  In "command mode (command mode)", press the ":" colon key to enter "Last line mode"
  1. Save and exit:
  press "ESC" in the upper left corner of the keyboard, and then enter "colon", that is, ":" ( No double quotation marks), a colon will appear below, waiting for the input command; the input is WQ (W: write, write; Q: quit, exit), press Enter, save and exit
  ": wq" (input "wq", save and exit vi)
  Actually, there are two ways to save and exit:
A: When inputting the command at the end, directly input "x", which is the same, that is, X=WQ.
B: The quickest method: After pressing ESC, directly press shift+zz, or switch to uppercase mode and press ZZ, you can save and exit, that is, press the uppercase Z twice.
  2. Normal exit:
  There is a precondition for normal exit: the open text file has not been changed in content.
  Press ESC and then enter the colon. When entering the command, directly enter "q"
  3. Exit without saving: Many times, after opening the file or modifying some places, only to find out that it is wrong. It is very necessary to exit without saving.
  Press ESC first, then enter the colon, when inputting the command, directly input "q!"
  ": q!" (input q!, force quit vi without saving)
  4. Force quit
  Press ESC first, then the colon, and then enter the command , directly enter "!", but after exiting, there will be a prompt!
: w filename (enter "w filename" to save the article with the specified filename filename)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325648608&siteId=291194637