In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to select text and use logos in Vim. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
A text or source code editor based on a graphical interface that provides features such as text selection. I mean, maybe most people don't think it's a function. But this is not the case with command-line-based editors like Vim. When you only use the keyboard to operate Vim, you need to learn specific commands to select the text you want. In this tutorial, we will discuss the text selection feature in detail, as well as the logos in Vim.
Before that, it is important to note that the examples, commands, and instructions mentioned in this tutorial are all tested in the environment of Ubuntu 16.04. The version of Vim is 7.4.
Text selection function of Vim
Let's assume that you already have the basic knowledge of the Vim editor. You should know that the d command can cut / delete a line. If you want to cut 3 lines, you can repeat the command 3 times. But what if you need to cut 15 lines? Is it a practical solution to repeat the d command 15 times?
Apparently not. The best way to do this is to select the line you want to cut / delete, and then run the d command. For example:
If I want to cut / delete the first paragraph of the INTRODUCTION section in the screenshot below:
So what I do is: place the cursor at the beginning of the first line (make sure you exit Insert mode) and press the V (that is, Shift+v) command. At this point, Vim turns on view mode and selects the first row.
Now, I can use the arrow key "Down" to select the entire paragraph.
That's what we want, right? Now you can cut / delete the selected paragraph simply by pressing d. Of course, you can do anything with the selected text except cut / delete.
This brings us to another important question: what do we do when we don't need to delete the entire row? That is, the solution we just discussed applies only to situations where you want to operate on the entire row. What if we just want to delete the first three sentences of the paragraph?
In fact, there are corresponding commands-just use lowercase v instead of uppercase V. In the following example, I use v to select the first three sentences of the paragraph:
Sometimes, the data you need to deal with consists of separate columns, and your requirement may be to select a specific column. Consider the following screenshot:
Suppose we only need to select the second column of the text, the name of the country. In this case, you can place the cursor over the first letter of the column and press Ctrl+v once. Then, press the arrow key "Down" to select the first letter of each country's name:
Then press the arrow key "right" to select this column.
Tip: if you selected a text block before, and now you want to reselect that text block, just press gv in command mode.
Use Fla
Sometimes, when you are working on a large file (such as a source code file or a shell script), you may want to switch to a specific location and then go back to the line you were just on. If the two lines are not far apart, or if you don't do this kind of operation often, then this is not a problem.
However, if you need to frequently switch between the current position and some distant lines, then the best way is to use flags. You just need to mark the current location, and then you can return to the current location from anywhere in the file by the flag name.
In Vim, we mark a line with the m command followed by a letter (the letter represents the flag name, which can be in lowercase a-z). For example, ma. Then you can use the command'a (including the single quotation marks on the left) to return to the line marked a.
Tip: you can use "single quotation marks" to jump to the first character of the flag line, or use "backquotation marks" to jump to a specific column of the flag line.
The logo function of Vim has many other uses. For example, you can mark a line, then move the cursor to another line, and run the following command:
D'[flag name]
To delete everything between the current location and the flag line.
In the Vim official documentation, there is an important content:
Each file has some flags defined by lowercase letters (amurz). In addition, there are some global flags defined by uppercase letters (Amurz) that define a location in a particular file. For example, you may be editing ten files at the same time, each of which can have a flag a, but only one file can have a flag A.
We have discussed the basic use of lowercase letters as Vim logos and their convenience. The following excerpt is clear enough:
Due to various limitations, the uppercase logo may not be as useful as the lowercase flag at first glance, but it can be used as a fast document bookmark. For example, open the .vimrc file, press mV, and then exit. The next time you want to edit the .vimrc file, press'V to open it.
Finally, we use the delmarks command to remove the flag. For example:
: delmarks a
This command removes a flag from the file. Of course, you can also delete the line where the flag is located, so that the flag will be deleted automatically.
This is the end of this article on "how to select text and use logos in Vim". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please 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.