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

What is the most basic use of VIM in Linux system

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

Linux system what is the most basic use of VIM, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.

Vim is linux under a very powerful text editor, every programmer should be proficient in using, the following for you to share the Linux system in the most basic use of Vim, master the tutorial can be said to have been started.

Introduction to Vim:

Vim is a text editor developed from vi. The convenient programming functions such as code completion, compilation and error jump are particularly rich and are widely used by programmers. Juxtaposed with Emacs as the favorite editor for users of Unix-like systems.

The first version of Vim was released by Bram Miller in 1991. Originally abbreviated as Vi IMitation, with the increasing number of features, the official name was changed to Vi IMproved. Now it is free software released in open source mode.

Specific methods of using Vim in Linux system: first, three modes of vim

(1) insert mode

You can only enter text in insert mode; to enter insert mode, press "I"; if you want to enter insert mode, switch directly to the next line and type "o"

(2) Command mode

In the command mode, the main functions are cursor movement, Chinese paragraph selection, deletion, copy and so on. When entering the command mode from insert mode and bottom line mode, press "esc" directly.

(3) bottom line mode

In the bottom line mode, you can save and exit the text; to enter the bottom line mode, you need to enter the command mode, and then press "Shift+:" directly, which will appear in the lower left corner of the editing page.

Description of functional commands (you can enter commands in:):

Set nu: line number appears in text

W: save and stay on the current editing page

W xxx.sh: save the current text with the file name xxx.sh (in this case, instead of entering the editor in the form of a file, you enter vi directly on the command line to enter the editor. In this case, the text of the editor has no corresponding file)

Q: exit

Second, the basic steps of using vim

Here is mainly to create a shell script as an example.

(1) first go to the Linux desktop and create a folder to store the text.

(2) right-click, select "Open in Terminal", and shell command line appears.

(3) you can enter the vi command on the command line

Enter vi; to go directly to the vim editor, where you press I to enter insert mode

If you enter vi hello1.sh, you will go directly to the vim editor. If there is no hello1.sh before, the editor will be displayed as a new file. For new files, when you finish editing the contents and save them (Esc, Shift+:, w), you will directly create a hello1.sh in the current directory.

If you enter vi hello1.sh, you will go directly to the vim editor. If hello1.sh already exists, you can directly render the text content in the editor and edit it.

The yellow part of the picture is the content that exists in the original file.

Enter vi, open the editor, write the content at this time, when saving, you need to specify the file name.

Hello3.sh is the newly created text.

Typing vim + hello3.sh will go directly to the contents of the hello3.sh, and the mouse will be moved to the end.

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

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

Development

Wechat

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

12
Report