In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you "linux how to use the Vi/Vim editor", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "linux how to use the Vi/Vim editor" this article.
The VI editor is a powerful command-line-based text editor that was first developed for Unix systems and later migrated to many Unix and Linux distributions.
There is also another advanced version of the VI editor on Linux-VIM (also known as VI IMproved). VIM just adds more features to the already powerful features of VI, such as:
Support for more Linux distributions
Support for code block folding and syntax highlighting in a variety of programming languages, including python, C++, perl, etc.
Support for editing files through a variety of network protocols, including http, ssh, etc.
Support for editing files in compressed archives
Multiple files can be edited on separate screens at the same time.
Next we will discuss the commands and options for VI/VIM. In this article, for teaching purposes, we use VI as an example, but all commands can be used for VIM. First, let's introduce two modes of the VI editor.
Command mode
In command mode, we can perform tasks such as saving files, running commands within VI, copy / cut / paste operations, and find / replace. When we are in insert mode, we can press the Escape (Esc) key to return to command mode
Insert mode
In insert mode, we can type the contents of the file. Press I in command mode to enter insert mode.
Create a file
We can create a file with the following command (LCTT note: if the file exists, edit the existing file):
$vi filename
Once the file is created or opened, we first enter command mode, and we need to enter input mode to enter content in the file. We have a general understanding of these two models from the previous article.
Exit Vi
If you want to exit from insert mode, we first need to press Esc to enter command mode. Next, we can use two commands to exit Vi according to different needs.
Do not save exit-enter: Q! in command mode
Save and exit-enter: wq in command mode
Move the cursor
Let's discuss the commands and options for moving the cursor in command mode:
K move the cursor up one line
J move the cursor down one line
H move the cursor one letter to the left
L move the cursor one letter to the right
Note: if you want to move multiple lines up or down, or move multiple letters to the left or right with one command, you can use 4k or 5l, which will move 4 lines up or 5 letters to the right, respectively.
0 move the cursor to the beginning of the line
Move the cursor to the end of the line
NG moves the cursor to the nth line
G move the cursor to the * line of the file
{move the cursor to the previous paragraph
} move the cursor to the next segment
In addition, there are some commands that can be used to control the movement of the cursor, but the commands listed above should be able to meet the needs of daily work.
Edit text
This section lists some commands for command mode, and you can enter insert mode to edit the current file
I insert content before the current cursor position
I insert content at the beginning of the line where the cursor is located
An insert content after the current cursor position
An insert content at the end of the line where the cursor is located
O add a line after the current cursor line
O add a line before the current cursor line
Delete text
The following commands can only be used in command mode, so you first need to press Esc to enter command mode if you are in insert mode:
Dd deletes the entire line where the cursor is located. You can add numbers before dd. For example, 2dd can delete two lines starting from the line where the cursor is located.
Delete from the position of the cursor to the end of the line
Delete from the cursor position to the beginning of the line
Dw deletes everything from the cursor position to the beginning of the next word
Copy and paste
Yy copies the current line, adding numbers before yy can copy multiple lines
P paste the copy line after the cursor
P paste the copy line before the cursor
These are all the contents of the article "how to use the Vi/Vim Editor by linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.