Notes on playing vim-(i)
Brief introduction
On this blue planet, there are legends of two great artifacts: Emacs is said to be the editor of God, and Vim is the god of the editor. Some people bravely picked up vim or Emacs, but found that the learning curve is steep and long, or some people stayed, firmly guarding the two great artifacts. Some people who say the grapes are too sour want to leave and are unwilling, always asking: Where in the world is God? But here I only introduce the legendary editor of God-vim. Vim is one of the most popular variants of VI, in addition to inheriting the VI swiftness of the editing method, the function of vim is much more powerful than the original VI. This also benefits from the ability to extend infinitely with vim scripts. There are already thousands of scripts on the vim.org, adding a variety of features and functions to vim. And its design is more in line with the Unix tradition, it through the pipeline mechanism and the system of various building block tools to deal with, it is fastidious with the system within the tool program to complete the user's task. In addition, its positioning is quite clear, is to make a powerful editor, so it is the vast majority of expansion, is to better complete the task of editing text. The author of the predecessor VI of Vim, Richard Stallman, author of Bill Joy and Emacs, is the famous hacker of that era, so the first major user of the two editors was the one who wrote the program, and it is still. They add more and more support to programming, such as syntax highlighting, smart indenting, keyword completion, and even integrated debugging.
First glimpse of the doorway
If you want to play, first you need to install a vim again. Since my development is usually done on CentOS, let's say it's installed. In fact, it's a line of command:
1 [email protected] ~]# Yum install vim 2 Loaded Plugins:fastestmirror 3 Setting up Install Process 4 Loading mirror speeds from cached Hostfile 5 epel/metalink | 4.3 kB 00:00
Now that the VIM installation is complete, don't do anything first, and then look down:
1 [[email protected] site-packages]# vim site.py
You will then see the following interface:
1 def __boot (): 2 Import sys, IMP, OS, Os.path3 PYTHONPATH = Os.environ.get (' PYTHONPATH ')
at this time into the so-called regular mode (normal mode), since the concept of the model, then the details of the two models of vim.
Normal mode and insert mode (insert modes):
General mode: can be edited to do some of the existing text, including: Copy, Cut, move, modify, delete, format and so on.
Insert mode: that is the legendary input.
And most of the editors have only one mode, the above two parts of the operation is merged together, this is why there are menus and buttons, and for the range of text selection also requires additional methods to assist, such as shortcut keys and mouse operation. No matter what the situation we have to force the brain in the thinking (input) and looking (edit) The constant conversion, even if you do not care about this, there are always some operations you can not flow. For example: when the cursor at random to stay somewhere, you can close your eyes with a mouse click to a function? Vim is available. In other words once you have mastered vim, all actions--------------------all the operations can be done without searching, without the help of a mouse, and you can devote yourself to your main goal.
so the question is, how do you switch between the two modes?
Actually, it's very simple. After entering the file directly is the normal mode, then from the normal mode into the insertion mode only need to choose from the following several commands:
1 I: Insert on the left of the current character 2 I: Inserting at the beginning of the current line 3 A: Insert to the right of the current character 4 A: Insert at the end of the current line 5 o: Insert a new row below the current line 6 O: Insert a new row above the current line
so how to go from insert mode to normal mode, the most common are three kinds:
-
  ESC
key: This is the most common method, its only drawback is the distance from the standard keys, but because it is located in the upper left corner, so you can also do some reinforcement exercises to accurately find it. Remember: Do not look at the keyboard to find, to form a muscle memory! There are also many people who prefer to modify   ESC
keying, such as transferring it to , CapsLock
, which is the CAPS LOCK key, is desirable and effective, but I do not recommend it. Because changing the keys is relatively cumbersome, in some scenarios it can be quite inconvenient for you. For example, you go to the customer to install the server, encountered almost all the standard keyboard, not only in the Vim to make you uncomfortable, other places also, because   ESC
is too often used, and there is no second alternative key.
-
  ctrl-[
key combination: Its function and   ESC
is completely equivalent, just a little more difficult to combine the keys. The trick here is   Ctrl
The position of the key, I will remap it to   CapsLock
key up. So the little finger of the hands can be moved slightly to complete, a bit of training can be mastered. This is also I do not recommend   ESC
The second reason, as to the previous mentioned the key mapping brings the Sequela, does not matter, the keyboard has more than one   Ctrl
, you don't need to adjust the keys at all.
-
  ctrl-c
key combination: It appears to be more than   ctrl-[
Span class= "Apple-converted-space" > is easier, but their meaning varies greatly. Under terminal   ctrl-c
means "break", basically it will abort all running commands, of course it can also be in Vim take us to interrupt all operations return to the default general mode. However, Vim has some operations that rely on the normal return method, that is,   ESC
or   ctrl-[
, using   ctrl-c
Can cause such a function not to be effectively triggered (many plugins rely on these triggering functions, so be careful with inexplicable problems). All in all, this is the least recommended method, unless you have a lot of heart and can use the first two methods at the right time.
Yes, The introduction of the model to this end, before the real play, the special recommendation to learn Vim's mobile command: The basic movement of Vim is   h
  J
  k
  l
these four keys, respectively, representing   left
  down
  on
  right
.
1 h cursor moves left /span>2 3 k cursor up 4 l cursor Move right
Is it special? Well, I admit it's weird. However you have to get used to them and never change their keys! This way you can move quickly without a small keyboard, and of course, the main thing is that you can still move your fingers without much movement. And why is it so designed? It seems that the keyboard is so designed. Don't believe words poke here.
very difficult to remember, It's hard to practice, isn't it? Don't want to practice, do you? Okay, here are four interesting things to believe you will unknowingly fall in love with these arrow keys:
- vim adventures This is an online game, play super simple, The control keys are all Vim's moving instructions. All you have to do is take the keyboard as a handle and move a shadow to find letters, characters, treasures, keys, and so on. If you are not able to cross the border, it is important to control the direction of this link can be practiced without thinking and do not make mistakes.
- vim snake if you think the last game was a little hard, Because can not pass to let you have frustration feeling, this game is much simpler--snake, who can't play? But you can only use  
h
J
  k
  l
to control the direction. Note that only in insert mode ( I
) can you eat something, and you can move the direction only in normal mode ( ESC
). The complete process is as follows: with Target----------------" i
until the target is eaten, quickly press   ESC
-> moved. About the pattern, we explain next time.
- Open Vim Tutorials If the above two games are embarrassing for you (hey, aren't you?!) ), then this is your savior. Skip to the third chapter of exercise four, and wait until you get used to the feeling and continue to challenge the game.
- Vim Genius This is also a good thing, it is closer to the philosophy of vim than the previous one. It does not let you see which key to press, but to give you a text hint to make you blind to the corresponding key, the advantage is to exercise their own muscle memory and reflex thinking. However, it depends on your self-control ability and patience, in addition, English is not good also a little drag.
At this point, the door of vim has been opened, and this is the end of the introduction.
Above. Enjoy vim!
PS: This blog Welcome to forward, but please specify the blog address and author, because I level limited, if there is wrong, welcome point, Thank you ~
Blog Address: http://www.cnblogs.com/voidy/
Blog: http://voidy.net
<. ))) ≦
Notes on playing vim-(i)