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 > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail what are the skills for the use of vim, and the content of the article is of high quality, so the editor will share it for you as a reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.
1. Common operations of VIM
1. Insert command
An insert after the character where the cursor is located
An insert at the end of the line where the cursor is located
I insert before the character where the cursor is located
I insert at the beginning of the line where the cursor is located
O insert a new line under the cursor
O insert a new line under the cursor
2. Positioning command
: set un sets the line number
: set noun cancels line number
Gg to the first line
G to the last line
NG to nth line
: n to nth line
Move $to the end of the line
0 move to the beginning of the line
3. Delete command
X delete the character where the cursor is located
Nx deletes n characters after cursor location
Dd deletes the line of the cursor
Ndd deletes n lines
DG deletes the content from the line of the cursor to the end of the file
D delete the content from the cursor to the end of the line
: N1 ~ (nd) n2d deletes the specified range of lines
4. Copy and cut commands
Yy copies the current line
Nyy copies the following n lines of the current line
Dd cuts the current line
Ndd cuts the following n lines of the current line
P paste the next line of the current cursor
P paste the previous line of the current cursor
5. Replace and cancel commands
R replaces the character where the cursor is located
R replaces characters from the cursor and ends by pressing the ESC key
U cancel the previous operation
6. Search or replace
/ string where string is the string you want to search, and search ignores case: set ic
N search for the location of the next character
:% s/old/new/g replacement string
N1Magol n2sUniverse OldUniverse G replaces characters within a specified range
7. Save and Save as Command
W save changes
W newfile save as specified path file
ZZ saves changes and exits
: q! Do not save changes and exit
: wq! Force to save changes and exit (available to file owner and root)
Second, the skills of using VIM
1. Import file contents and command results
R / etc/111 the output of the import file to the cursor location
: r! Command Import Command execution results to the cursor location, such as: r! cat / etc/redhat-release
2. Define shortcut keys
: map ^ P I# Note ^ P is set by holding down ctrl+v+p at the same time. P is the shortcut key to be set. I# means to insert # at the beginning of the line and return to command mode. You can also press ctrl+v first, and then press ctrl+P to set it. When using the shortcut key
You can use ctrl+P.
3. Continuous comment lines
: N1Magol n3s / ^ / # / g n1Magee n3 represents the first and third lines, and ^ indicates the beginning of the line, which means to add # to the beginning of 1-3 lines
: ab mymail heruiguo@163.com replacement
Once the server is restarted, all the fast keys set will become invalid. We can write it into the configuration file and create a new vimrc under the current user's home directory, taking root users as an example.
In vim / root/.vimrc
Set nu
Map ^ P I#
On the use of vim skills to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
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.