Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Which is the command for linux to exit the vi editor

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces which is the command for linux to exit the vi editor, which has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

Linux exit the vi editor command: 1, use ": wq" or ": X" or "ZZ" command to save exit; 2, use ": Q" command to exit normally; use ": Q!" You can exit without saving; 4. Use ":!" Can be forced to exit.

The operating environment of this tutorial: Red Hat Enterprise Linux 6.1 system, Dell G3 computer.

In Linux, the vim editor is the system's own text editor, but to modify a text file, it is not like Windows operation, but more novice, after entering the vi editor, can not exit to force shutdown, in fact, this vim (vi) is also very simple.

1. Enter the vim editor

Vim editor, you can create or modify files, the command is: vim / usr/local/con.cfg

If the file was not previously available, it is new, then there is a prompt below for the new file, and if the file already exists, there is no prompt.

After entering the editor, we first press "I" to switch to the "insert" state. You can edit the content by moving the cursor or spaces up and down, backspace and enter, which is the same as Windows.

2. The method and difference of exiting vim editor.

When the text editing is finished, it is usually necessary to exit the editor, and the exit editor can be divided into four cases: save exit, normal exit, unsaved exit and forced exit.

① save exit

When we edit or modify the contents of the file, of course we have to save and exit and then move on. At this point, we have to press the "ESC" in the upper left corner of the keyboard. Have you noticed? The insertion status in the lower left corner is gone, and now it enters command mode.

Then, at this time, we enter the "colon", that is, ":" (without double quotes), the colon appears below, wait for the command to be entered, and type "wq". The function is as follows:

W:write, writin

Q:quit, quit

Enter the car again and save and exit. In fact, there are two ways to save and exit:

A: when you type the last command, type "x" directly, which is the same, that is, x=wq.

B: the quickest way: after pressing ESC, press shift+zz directly or switch to uppercase mode and press ZZ, you can save and exit, that is, press the uppercase Z twice.

We can view its contents with the view command cat: cat / usr/local/con.cfg.

② exits normally

A prerequisite for a normal exit is that the open text file has not been altered in content. Press ESC and then enter "colon". When entering the command, enter "Q" directly.

③ does not save exit

Very often, when you open the file or modify some places, you find that it is wrong and need not to save and exit. Press ESC first, then enter "colon". When entering the command, enter "Q!" directly.

④ forced exit

Less commonly used operations, first press ESC, and then press "colon", in the input command, directly enter "!", after exit, there will be a prompt!

Note: Linux commands should be lowercase!

Thank you for reading this article carefully. I hope the article "which is the order for linux to exit the vi editor" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report