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

How to use the ubuntu16.04 editor vi

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article introduces the knowledge of "how to use ubuntu16.04 editor vi". Many people will encounter this dilemma in the operation of actual cases, 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!

First: command mode (command mode)

That is to say, in this interface we can execute commands to complete the operations we need to complete, for example, we directly enter the command in the terminal: vi, here we can see that the system has entered the vi system interface, showing the vi version and some simple help functions. When we type: "vi + file name", we enter the file editing state. For example, we write a hello.cpp file and type: vi hello.java on the command line.

The place where the cursor is displayed is the command editing office, where we can carry out command operations on the file, such as moving the contents of the file, deleting characters, words or lines, or entering the editing state, saving and exiting, and so on. The lower left corner shows the new file name.

Second: insert mode (Insert mode)

In vi, only enter the insert mode to write and edit the contents of the file, the method is very simple, as long as in the command mode (command mode) enter the "I" key to enter the insert mode (Insert mode), this is also a lot of novice contact with vi confused place, editor before, want this configuration, half a day do not know how to enter content.

For example, the editor writes a simple helloword:

Public class HelloWorld {

Public static void main (String [] args) {

System.out.println ("Hello World!")

}

}

After writing, press "esc" key to exit "insert mode (Insert mode)"

Third: bottom line mode (last line mode)

It is the operation in the last edit of the vi text, that is, the upper box of the file name displayed in the lower left corner, which is usually used to save or exit vi editing of the file.

The way to do this is to enter the bottom line mode (last line mode) by pressing the colon key in the command line mode (command mode). We can see a ":" in the lower left corner, which means you have entered the bottom line mode (last line mode).

Finally, we save the text.

W xxx ("XXX" here saves the file with the specified file name "XXX")

: wq (enter "wq" to save the disk and exit vi)

: q! (enter "Q!", then do not save the disk and force to exit vi)

Here editor type wq to save the current file, let's see if it has been created to see the hello.java file, in the terminal enter the command: ls, we can see that the white file name is the hello.java file we just created, if you want to see more information, enter the command: ls-l.

In this way, we have completed the operation of the entire file in the vi editor.

Special note: if you want to delete mistyped characters in insert mode (Insert mode), it is invalid to use "backspace". The cursor will only move forward, and the characters will not be deleted. In vi, you can modify the file content by using the character command directly in the command mode:

"x": each time you press, delete the character where the cursor is located.

"X": uppercase X. each time you press it, one character in front of the cursor is deleted.

Of course, if you want to delete in insert mode (Insert mode), use the "del" key to delete the character where the cursor is located.

This is the end of "how to use the ubuntu16.04 Editor vi". 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.

Share To

Servers

Wechat

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

12
Report