Home > Article > Operation and Maintenance > Recommend two very practical vim plug-ins - quick positioning and paired editing
Today I will introduce to you two very commonly used vim plug-ins for fast movement within the page and paired editing.
easymotion
We know that the vim editor can move up and down by pressing h/j/k/l, and use the / keyword to search , use the w and e keys to move quickly between words, use f{char} to search within a line, and so on. However, none of these have a way to move quickly across the page.
Today I introduce easymotion, a quick movement plug-in. With it, you can go wherever you want. The plug-in github address is: https://github.com/easymotion/vim-easymotion
Similarly, we use the vim-plug plug-in to install it. Then add a line of mapping to the configuration file
nmap ss
Did you notice that what we need here is recursive mapping, not non-recursive mapping. After configuring it, we can use it. The following demonstrates how to use it to complete the function of quickly moving on the page.
As shown in the picture, we want to quickly move to the layui position on line 9. If you don't use easymotion, you need to use vim's built-in search, enter
/layui
and then use n/N to move up and down. If you use easymotion, it will be simpler and faster. Just press two ss and enter la.
You can see that the interface is different now. All positions matching la are marked in red, and each block has its own corresponding letter. . As long as we press the corresponding letter, we can quickly jump to the specified position.
vim-surround
In daily work, we often encounter pairs of editors. For example, replace the single quotes in the string with double quotes. At this time, if there is no paired editing plug-in, it will be more troublesome. You need to modify it twice to complete the requirements.
Now, let’s install the plug-in first. The plug-in github address is https://github.com/tpope/vim-surround.
After the installation is completed, let me talk to you about how to use it. It will be mainly explained from three aspects: paired modification, paired addition, and paired deletion.
Now, we want to replace the double quotation marks in the where in line 25 with single quotation marks. How to do it.
First move the cursor to any character in ""
Enter cs"'; cs (c means change), which means changing the double Change the quotation marks to single quotation marks
If you want to delete the double quotation marks in pairs, what should you do?
Move the cursor to "" Enter ds" on any character
, d means delete
The double quotes have been deleted, but now you need to add double quotes. How to do it
Move the cursor to i
Enter ysiw"
The above is the detailed content of Recommend two very practical vim plug-ins - quick positioning and paired editing. For more information, please follow other related articles on the PHP Chinese website!