Vim user experience-general Linux technology-Linux programming and kernel information. The following is a detailed description. Vim is a text editing software known as the "God of editors". Since its exposure to Vim, Vim has basically been used to modify and compile code and configuration files.
However, I always only use the most basic commands, although I have mastered the HJKL positioning key. But other powerful aspects of Vim have hardly been touched.
If you want to learn something, you must learn it.
This time, I re-wrote Ubuntu Tweak and started to thoroughly learn Vim. As a result, I will start to serialize my Vim learning journey from today. The article will only write some tips that you did not know before.
Merge rows 1 and 2 into one row:
Int
Main (int argc, char argv)
If you want to merge the preceding two rows into one row, you only need to locate the int row and press J (uppercase.
Ii. Undo and redo
I used to be silly. I only knew to undo it by pressing u, but I didn't know how to redo it. Not careful, it's silly to undo it too much. The original redo is Ctrl + r.
In addition, uppercase U is used to undo the entire row.
3. Insert n consecutive exclamation points
I/a used to assume that I/a cannot be used to insert multiple consecutive characters. It turns out to be wrong!
Hello World
For example, insert 10 "! ", You cannot really beat 10, right?
You just need to calibrate the light in d, and then press 10a !...... No, it's just one !, Don't worry. Press Esc twice! Haha, ten! Now!
4. Save and exit
Before that, I will use two exit methods:
Save and exit: wq
Do not save and exit: q!
Now there is a faster way to save and exit-simply press ZZ in normal mode.
In addition, use: e! You can save the file and reload it.
5. Move and scroll
I don't know how to roll words by w! I often use dwdw to delete words.
In addition, Ctrl + D scroll down and Ctrl + U scroll up, which is more efficient than jjjjkkkkkk ...... Khan
I don't know where it is?
: Set number to display the row number, or press Ctrl + G to display the current row number.
6. case-insensitive and Historical searches are ignored during search.
Sometimes you need to ignore the case when searching words. You only need to set the following.
: Set ignorecase
If you have performed several searches and want to continue searching with the keywords you have previously checked, you only need to press/and then select the upper/lower key.
Similarly, press:, and then press the up or down key to view the history of the execution, but only the current editing.
VII. Quick Search
If you want to find the field at the position of the current cursor, do you need to slowly input/and fields? No! Press the * number directly, and Vim uses the current field as the search content to find the next one.
By the way, set hlsearch can highlight the searched content. This looks good. Add: set nohlsearch. The above ignorecase can also be added with no.
8. Define tags
Only now can we find this extremely useful thing! Sorry!
In the past, in a C file, I jumped from one method to another, and jumped from one method to another. They all recorded the number of rows ......
Originally, press ma to mark a column a in a row, and then you can access this place through 'a! In addition, you can use 'a to access the beginning of the row at that position.
Run the command: marks to view all the tags.
If you only press ', you can jump between the last two tags!
"Is back to the last time when the file was edited.
You can use [and] to access the start and end positions of the last modification!
IX. Replace text
* Use cw or ce to replace the word with the cursor, and the effect is the same;
* If you press cc, replace the whole line directly. In addition, S can achieve the same effect;
* Press C = c $ to replace the content from the current row to the end of the row;
* S is used to replace the current character, which is the same as r;
* Use d $ to delete a row from the beginning to the end. The original D is enough;
Most of the above can be added with numbers!
10. Visual Selection
* Select by v. If you want to control the head and tail, switch by o/O;
* If it is an uppercase V, select it by row;
11. delete words and replace sentences
* In general, to delete a word with dw/de, You need to mark the light at the beginning of the word, but if you use daw, This is not required, as long as the cursor is over the Word (daw = Delete a Word), if it does not contain spaces, It is diw;
* Replace the sentence with cis.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.