Home  >  Article  >  Operation and Maintenance  >  Is vim based on linux?

Is vim based on linux?

青灯夜游
青灯夜游Original
2023-03-20 10:06:511118browse

Yes. vim is an editor based on the Linux environment; it is an external software that comes with Linux and is responsible for editing code. Vim is a text editor developed from vi. It has rich functions that facilitate programming, such as code completion, compilation and error jumping, and is widely used among programmers.

Is vim based on linux?

#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.

What is vim

vim is an editor based on the Linux environment; vim is the external software that comes with Linux and is responsible for Edit the code. If we want to program under Linux, we need four things to replace the integrated development environment of vs. The most core carrier is the vim editor. Without it, we can't even write code.

Vim is a text editor developed from vi. It is particularly rich in functions that facilitate programming, such as code completion, compilation, and error jumping, and is widely used among programmers.

To put it simply, vi is an old-fashioned word processor, but its functions are already very complete, but there is still room for improvement. vim can be said to be a very useful tool for program developers.

In addition to the classic editor vim under Linux, there is another editor that is also loved by everyone, which is emacs. There are several main reasons why these two editors are so popular that no editor in the following decades can surpass them.

1. Supports rich shortcut keys and editing methods.

2. Supports very powerful expansion capabilities.

3. All are supported by a powerful programming language.

Speaking of the programming language that supports them, we have to mention the programming language behind emacs lisp. We used to say that everything comes from C language, but this is not the case. In addition to C language, there is another programming language that is the ancestor of lisp. These are two programming languages ​​with very different styles. If you are interested, you can learn about them yourself. I won’t go into details here

Although vim and emacs are two editors that have their own merits and are both the ancestors of editors, I choose emacs as my preferred editor and also as the explanation below. The key point (if any students are interested in emacs, they can naturally choose emacs as their first choice), and the best thing is that every Linux system comes with the vim editor, so we don’t need to install it ourselves.

vim use

Basic introduction to vim

Since our Linux already comes with vim , so we can use it directly. Enter vim to see its interface.

Is vim based on linux?

#You will find that the interface of vim is very ugly. After all, it is under the console, which is helpless. So how to exit the interface? Enter :q to exit. Note: There must be a colon in front of it! .

Is vim based on linux?

Regarding the use of vim, vim actually has an official teaching document. After exiting the vim interface, enter vimtutor to enter the official teaching document. (Enter vimt tab to complete it. tab is the completion key that can help us quickly enter commands, so it should be used frequently).

In the official teaching document, everyone follows the teaching steps and practices step by step. With a lot of practice, you can master all common operations of vim. Remember one thing: Never memorize instructions or shortcut keys while using them. Memory is the best policy.

There are normal, insert, command, visual, and replace under vim. When we use vim to open a document, we enter the normal mode by default. , it is more convenient for us to browse documents in normal mode. In this mode, we have a wealth of shortcut keys for us to perform conditions and move the cursor between pages. Insert mode is the mode we enter when we want to modify the document. There are some commands in the command mode that facilitate us to modify the configuration of vim, jump to pages, etc., with rich usage. Our most commonly used operation in visual mode is to select document fragments to delete, copy or cut. Replacement mode allows us to replace text content.

vim commands

vim has many shortcut keys and commands. Here we focus on introducing some commonly used commands. At the same time, vim is divided into several modes to facilitate shortcut key operations, and most of our shortcut keys are used in normal mode.

1. In vim, in addition to the up, down, left and right arrow keys to move the cursor, we also provide four new shortcut keys for us to move the cursor. j: Lower ; k: Upper ; h: Left ; l: Right . Under vim, it is especially recommended that you use these four direction keys to control cursor movement, because they are more convenient to use. The most important thing is that this is a symbol that you have learned vim!

 2. There are many ways to enter other modes from normal mode. The most common one is to press i to enter insert mode, : to enter command mode, and v Enter visual mode, R enter replacement mode. The most commonly used method to return to normal mode in other modes is always to press esc. Therefore, it often becomes a habit for programmers who use vim to press esc

3. x to delete a single character.

4. Enter the command vim file name in a directory to open an existing file or create a new file. Enter : to enter command mode, enter w to save, q to exit, wq to save and exit, q! Force exit without saving.

5.

w can move the cursor from the current position to the head of the next word, e can move the cursor from the current position to the end of the next word, $ can move the cursor to the end of the line, b means moving to the beginning of the previous word.

6.

d represents a delete command, usually used in conjunction with the cursor jump command. dw means deleting from the current cursor position to the head position of the next word (excluding the head), de means deleting from the current cursor position to the tail position of the next word (including the tail) ), d$ means to delete from the current position of the cursor to the end of the line (delete the entire line).

7. At the same time, we can use numbers plus instructions to repeatedly execute many instructions. For example

2w == w w, d2w==dw dw, etc. Wait, you can try it yourself.

8. In normal mode,

u means undoing the operation, and U means undoing the operation on the entire line. Ctrl r means redo and undo operations.

9.

ddDelete/cut the entire line, #  ##pPaste the content in the clipboard after the cursor, PPaste the contents of the clipboard in front of the cursor. 10.

r

will replace a single character, ##  #R will enter the replacement mode and replace the next input content with the input content until it returns to the normal mode. 11. The c

command is similar to the

d command, and still forms a combined command with other commands, such as cw, ce, etc. , but the difference is that the c command will enter insert mode after use. 12. Enter :

to enter the command mode, and enter

set nu to set the line number. 13. ctrl g

Displays the current line number and displays cursor position information.

14. shift g

jumps to the end of the text,

gg jumps to the beginning of the text, 'returns to the number of lines before jumping. 15. /Search content

Enter the command mode, enter the search content to search, and

nfind the next one, Nfind the previous one . 16. Press %

on the bracket to quickly move the cursor to match the bracket and automatically jump to the matching bracket.

17. Enter :

to enter the command mode and then enter

s/search content/replacement results/gc to replace the content of a line, %s/search content /Replacement result/gc performs full-text content replacement, where g means searching the entire line, c means asking before replacing, %s means full-text replacement. 18. o

Create a new row below this row and enter insert mode,

OCreate a new row above this row and enter insert mode. 19. v

Enter visual mode, move the cursor to select the statement and press

y to copy. At the same time, yy can copy a row. Use p or P similarly to paste. 20. a

Entering insert mode means inserting after the cursor, similar to

i. Also use I or A to insert at the beginning or end of the line. This is the introduction to the basic commands of vim. The use of vim is far more than these shortcut keys and commands. If you want to use vim better and more skillfully, you need to practice continuously. Learning in practice is the key. The most efficient.

Related recommendations: "

Linux Video Tutorial

"

The above is the detailed content of Is vim based on linux?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:What is linux yum sourceNext article:What is linux yum source