In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article shows you what are the basic commands of the must-know Vim editor, which are concise and easy to understand, which will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
Why the Vim editor is recommended
You are more likely to modify existing files than to create new ones. In this case, Vim shortcuts can effectively meet your needs.
What is Vim?
Vim is one of the most popular and powerful editors widely used by Linux administrators and developers. It can improve the efficiency of text editing through a highly customized configuration. It is an updated version of the Vi editor installed by default in many Unix.
Vim is often referred to as a "programmer's editor", but it is not limited to this, and it can also be used to edit any type of file. It has many functions, such as: multiple undo, multiple windows and buffers, syntax highlighting, command line editing, file name completion, visual selection, and so on. You can use the: help command to get online help.
Understand the pattern of Vim
There are two modes for Vim, which are described in detail as follows:
Command mode: when you start the Vim editor, it defaults to command mode. You can move and modify contents in the file, cut, copy and paste parts of the file, and issue commands to do more (press ESC to enter command mode)
Insert mode: insert mode is used to insert text at a given document location (press I to enter insert mode)
How do I know which Vim mode I'm using?
If you are using insert mode, you will see INSERT at the bottom of the editor. If nothing is displayed at the bottom of the editor, or if the file name is displayed at the bottom of the editor, you are in command mode.
Cursor movement in command mode
Vim shortcuts allow you to move the cursor in different ways:
G-Jump to the last line of the file
Gg-Jump to the first line of the file
$- Jump to the end of the line
0 (number 0)-jumps to the beginning of the line
W-Jump to the beginning of the next word (the word delimiter can be a space or other symbol)
W-Jump to the beginning of the next word (the word delimiter can only be a space)
B-Jump to the end of the next word (the word delimiter can be a space or other symbol)
B-Jump to the end of the next word (the word delimiter can only be a space)
PgDn key-move down one page
PgUp key-move up one page
Ctrl+d-move half a page down
Ctrl+u-move half a page up
Insert mode: insert text
The Vim shortcut below allows you to insert content at different locations of the cursor as needed.
I-insert before the cursor
A-insert after the cursor
I-insert at the beginning of the line where the cursor is located. This key is useful when the cursor is in the middle of a line
A-insert at the end of the line where the cursor is located.
O-insert a new line below the line where the cursor is located
O-insert a new line above the line in which the cursor is located
Ea-insert at the end of the word
Copy, paste, and delete a line
Yy-copy a row
P / P-paste the content behind / before the cursor
Dd-Delete a row
Dw-Delete a word
Search for and replace matching patterns in Vim
/ pattern-searches backwards for a given pattern
? Pattern-search forward for a given pattern
N-repeat the search back for the previously given pattern
N-repeat forward search for the previously given pattern
:% s / old mode / new mode / g-replace all old modes in the file with new modes
: s / old mode / new mode / g-replaces all old modes in the current line with new modes
:% s / old mode / new mode / gc-ask whether the old mode in the file is replaced with the new mode one by one
How to jump to a specific line in the Vim editor
You can achieve this in two ways according to your requirements, and if you don't know the line number, the first method is recommended.
Display the line number by opening the file and running the following command
: set number
When you have set the display line number, press: n to jump to the appropriate line number. For example, if you want to jump to line 15, enter:
: 15
If you already know the line number, use the following method to jump directly to the line when you open the file. For example, if you jump directly to line 20 when opening a file, enter the following command:
$vim + 20 [file name]
Undo operation / redo previous operation / repeat previous action
U-undo the change
Ctrl+r-restores changes
. -repeat the previous command
Save and exit Vim
W-Save changes without exiting vim
: wq-write and exit
: Q!-forced exit
What are the basic commands of the Vim editor that must know? have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are 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.