Newbies have just come into contact with Vim. I hope you guys can recommend some introductory practice tutorials. Now I just use Vim as a normal editor. Also, it seems a bit troublesome to press Esc to return to normal mode. You have to reach to the upper left corner of the keyboard. Hey, is there any easy way? First, thank you!
I have been using vim for almost two years and have read a lot of tutorials. Generally speaking, I still have to practice more by myself and add functions when I feel it is necessary. Here I will share the best tutorial I have ever seen. It was written by a friend from Tieba. It is very well written
Zero
Learn to touch type
一
Start with the simplest configuration file. Don’t consider configuring plug-ins before level 5. Don’t memorize commands by heart. Don’t directly use other people’s configuration files.
Basically, if you stay in insert mode for a long time, you will feel that vim is mediocre and not easy to use,
At this time, the editing efficiency may be lower than using the original general editor. When others ask what editor to use,
Most people will answer: vim with a nano, kate, kwrite, gedit, geany or other IDE
谰
Develop the habit of staying in normal mode (normal is not called for nothing). Enter insert mode only when typing. After typing, immediately <ESC>
Learn the movement commands in normal mode. The standard process for inputting text at this time:
At this time, the editing effect will return to the same as the ordinary editor you used before, or even slightly improved
三
Learn what an operator is (commands d y c, etc.), what is motion (all commands that can move the cursor, h j k l w e f t / ?, etc.),
Learn the method of operator + motion, such as ct. (Delete the content between the current cursor and . (point) and enter insert mode to prepare for modification)
Learn basic Ex commands, :s and so on
At this time, the editing efficiency begins to improve significantly. When using other general editors, you will start to feel uncomfortable and inefficient
四
Learn text-objects and know the method of operator + text-objects to perform surgically precise positioning and modification,
Since you are mainly using c/c++, here are some examples that are useful in this case:
ci" (consisting of change operator and text-object i")
yaB (consisting of yank operator and text-object aB)
gUiw (composed of make uppercase operator and text-object iw)
At this time, I began to understand why vim is accurate and efficient, and it’s not because of the full keyboard without the need for a mouse
五
After getting used to operator + motion, I found that the . command is very useful. Pay more attention to using repeatable command combinations
Practice using bookmark positioning, q to record macros, using multiple registers, using args, and using buffer
Use other Ex commands
At this moment, I can’t remember how I got through the days before vim was not used
LU
Start map commands that are often used repeatedly, start writing vimscript, and start to know what kind of plug-ins you need
Let’s try to recommend a few:
pathogen or vundle, tagbar, CtrlP, Gundo, UltiSnips, surround, Syntastic, Conque, ack.vim, vim-commentary, fugitive (if you are a git user)
There are many more, but most of them are not directly helpful to c/c++, so I won’t mention them
At this time, I have no interest in other editors, except maybe emacs
柒
Have a completely personalized vimrc, basically enter the realm of transformation, and become a legend in the world
People often observe you editing, and you are inspired to become ambitious and want to learn vim. After trying it for a few hours, you give up because you feel that the hotkeys are not "humane".
But occasionally he will mention to people that he has seen a person like you in the world
I have been using vim for a year. I am about to write a vim cheat sheet a few days ago, so I will write it here in advance.
First vim != gvim
1.How to edit
Press the ESC key at any time to enter normal mode. In normal mode, you can press: to enter commands.
Press i or a in normal mode to enter insert mode, then you can edit text.
2. Simple editing
3. Faster editing
Now you can write in vim.
We need faster editing
1. Quickly position the cursor:
2. Quick editing:
In normal mode:
3. More sophisticated paste and copy:
4. Search
In normal mode, press / to search down, press ? to search up
5. Alignment
gg=G quickly aligns the entire file
6. Label operation
7. Cutting window operation
4. Let vim understand you better
Have you noticed that we have not mentioned vimrc and plug-ins above.
The time has come.
For example, we like to display line numbers when coding: in command mode: set nu or :set number
About vimrc, there are many things worth studying and discussing. You can refer to my vimrc, I have made detailed Chinese comments
5. About plug-ins and themes
vim has three well-known color schemes, solarized, molokai and badwolf
About vim plug-ins, there are only a few words that need to be said:
Okay, let’s go eat. . That’s it.
Nothing but familiarity.
Also,
Ctrl-[
you can also exit the editing mode.Hi! I provide a great method:
Play vim games!
If you are using Ubuntu system, please enter:
Or via a cool web vim game:
vim adventurer
http://vim-adventures.com/
hey~! I really don’t know how to use vim, only my hands know. (Practice makes perfect)
If you don’t like using esc, you can use <c-c> or <c-[> with the same effect.
Read more vim tips and learn more about various vim plug-ins.
Then again, it’s just a text editor, don’t put the cart before the horse.
Separation lineBy the way, I recommend a vim plug-in collection called Janus, which defines itself as Janus: Vim Distribution. It provides a complete, necessary basic vim settings that most people need Plug-ins, and solutions to continue customizing vim. It’s useless to say more, RTFM.
Using vim mainly involves defining various functions yourself and using various plug-ins. The main thing is to configure vimrc. You can refer to other people's vimrc and search for vimrc on github, such as https://github.com/search?q=vimrc&ref... to see how others configure it and change it to your own. .
esc can be replaced by jj or jk.
After reading the built-in tutorial (there is a Chinese version, download link, you need to go through the firewall to download), but you don’t need to memorize it by rote, just remember what functions it has.
When you encounter a place that seems to be able to use these functions, start to check the tutorials, and then slowly you will check less and less, less and less, and slowly you will know it.
For example:
If you want to delete foobar, then you can use
ffdw
This combined command (f is a query in one line, and the f after it is the first letter of foober. This is the first part of the command. Move the cursor to the word foobar, and d is Delete, w is to select a word, and the combination is to delete a word), which is very fast and is a combination of simple commands.Then if you want to deal with more complex scenes, such as
Only delete the previous foo and leave the bar. Although vim provides processing functions at this time, we don’t need to worry about it. We use the macro recording function (which can save your operations and you can simply repeat them). By combining the commands, you can do a lot of complicated work
For example, in the above example (I don’t have Vim at the moment, I may be wrong from memory),
This is solved.
Vim is not difficult at all, because 90% of the situations only require a flexible combination of simple commands.
The status of the remaining 10% is also easy to know by checking the tutorial. If you ask someone who can use Vim to dictate commands, and compare all the commands, you will find that they only know a very small part.
The people above have said it in detail, but for the esc key, it is recommended to change the key to Caps Lock, which will be much easier to press.
It is said that when RMS wrote Emacs, the keyboard looked like this
Obviously, the distance between Esc and Control should be very comfortable. If you have money, buy a piece of HHKB.
http://vim-adventures.com/
A small game written based on vim operations. The game also practices vim operations.