Linux Job Skills First: VI

Source: Internet
Author: User

Do not know why, why typesetting so ugly.
OK, speaking of the first contact with Linux, the university operating system class, the training class do not know why it is written in the Linux Hello World, but also remember Red hat, I think the interface is pretty beautiful, ha, at that time already heard VI this thing, the teacher did not say we use what code, I and a friend do not know how to find a way, do not know how to knock a vim out, this what ah, typing can not come out, ask the teacher, the teacher, to enter the insert mode, and then I pressed the "insert" key, yo ah, teacher really good, sure enough to input, The crackling of a bunch of brain-free programming jokes, teacher Ah, how to compile and run Ah, this good, the teacher said first save quit, teach me to press: QW, according to the long time, "teacher, not ah", the teacher said "impossible", ran to give us light two God operation, cattle, still really quit, but the code is gone, Today think of that teacher is really enough cow,: Wq can remember, we become victims ah. In this way, the first time to VI abuse, do not play, boring.
Since then, also seen on-line lights on the VI function diagram, the entire keyboard dense what things ah, Lao Tze not to see, pretending to play VI, although I love to pretend, also do not carry such a dress. There are also a variety of big God said what Emacs, I think it must also be loaded, or so complicated, it is better to use Notepad.
Several years later, I found that I was wrong, in VS with VA used a few months, I found that although the function is indeed strong enough, in a variety of documents walk or very comfortable, but always feel the shortcomings of what, for example, I want to jump to the end of the bank, the most soil method is right-hand to the right to move in the direction of the key bar, Then advanced, know the end key, efficiency improved a lot of ah, but always feel that people are more and more lazy, hands do not want to move, this problem is a long time, since one day to see the god of God operation, I found that I am weak explosion, the original VI is such a use of ~ ~ ~ Well, nonsense not much to say, or to the recent learning

1. Cursor Movement
In addition to the traditional directional keys, VI allows you to move your right hand without moving the cursor, not to mention the use of the mouse, Linux mouse is useless.
The h,j,k,l represent ←,↓,↑,→ respectively. In the habit of such operations, stupid I took a little bit of God, accidentally moved wrong. These keys are for lazy people.
In addition to the above several basic quiet, VI mobile operation is indeed rich enough, the normal mode of 0 directly move the cursor to the beginning of the line, ^ moved to the beginning of the first non-empty characters, and the same as regular expression, relative to the end of the row, familiar with the regular expression of friends must know is $, that line end of the first non , G_ is, in fact, they can make up the first move to the end of the line, and then back to a word, then to the end of the word is done, that is, $be, in fact, $ge is also possible. See if you can remember which one you live in. Anyway, you can not rely on the mouse, do not have to move the delicate hand. In fact, I have spent so long va, do not know if there is no such operation.
Well, actually the above features have attracted me, but people are greedy, when I just want to move a word or a few words, repeated knocking h,l? NoNoNo, first press a number and then there will be surprise, wow, incredibly so magical, at that time I feel really hanging ah, but later, hey, this word a few letters I can't count it, the same thing again committed, OK, programmers are lazy, the designer has put you can lazy place all think of, visible he is really lazy ah. W,w, I think of him as the first letter of Word to remember, but w,w the difference between the 1:30 will still not remember, because most of the time the basic effect is the same, Hello-world, the cursor at h there, click W, found VI-also when a word, assuming that the W, He did not take--when the matter, a little understand, my understanding is that W is the programmer's use, he is facing most programming languages in the variable naming specification, numbers, _, letters. The three goods are composed and connected together I as a word, this time w,w no difference, assuming that there are other characters in the mess, I am sorry to be the word processing, w this goods only recognize the space, the above example changed to Hello_world words will not be the same, he is a word around. There is a forward, there must be a backward, b,b, right. Back, move backwards one word, and the case difference is the same as w,w. To move multiple words, the number in front of the numbers plus instructions, good scrim ah.
The word related to the instruction also has a e,e, moved to the current cursor in the word ending, above the $be, $ge have used the E brother AH. case, you know.
To move up and down, the number plus j,k is good, move to the file head, enter a large number, 999999k, sure enough to, 999999j, a bit to the end of the file, check the log often jump to the end of the file to see the wrong AH. I'm really smart. hahaha, until one day, I realized that I was a 2b.
GG directly jump file head, G Jump file end directly, it is simply ashamed of the dead.
There is nothing to move, absolutely forced to have, but I do not remember, remember or learn to fill it again. After all, the instructions are more than calf, the above also enough to deal with my usual work.
2. Insert
From the normal mode into the insertion mode, from the University of the Daniel teacher taught insert into the outside, there are i,i,a,a,o,o.
are good scrim instructions Ah, I use rate is the highest bar, the current cursor position into the insertion mode, a, is the current cursor position after a character into the insertion mode, the equivalent of L moved to the right of a grid and pressed a I, this a with a lot of.
I,a These two guys are more reliable and have high usage rates because they move and go into insert mode. The equivalent of using the moves above and then pressing an I or a.
For example, I would like to add a comment, i//is good, convenient. It's better than ^i//. There are a lot of things to add at the end of the line, press A, "has it started?" No, it's over, haha. "
3. Delete
BACKSPACE, can be used in insert mode, and many can be in normal mode.
X and Del usage almost, delete the following characters, 3x deleted 3, 4x delete 4, then the problem came, I want to delete the whole line to do, good to do, DD easy to fix, that I want to delete a word how to do, or do dw Ah, delete Word, a try, really can delete, But the deletion is the position of the cursor to the beginning of the next word, oh yo, with W should be b,db a try, oh yo, sure enough, deleted the word head, left a tail, a long time, in order to delete the current word, my operation is, B DW, and then I, continue to write, then did not think so much, think still do. Over time, I think there must be a way, sure enough, method to remove the cursor position of the Word method is to add a word in the middle of the DW, I or a. These two instructions have nothing to do with the previous insert instruction, but the use is very large. Can be combined with the N-multiple instructions, is a delicious dish ah.
I what is the abbreviation I do not know, I personally understand is in, I primary school English water bottle, in what what in so remember, a where rote became all, shameful disgrace, all the meaning. Diw,daw all deleted the cursor in the whole word, but there are differences, assuming that the word is followed by a space, DIW will not delete the following space, the DAW is relatively strong, the space is also deleted.
d$ is deleted to the end of the line, d^ deleted to the beginning, DG deleted to the end of the file, DGG deleted to the file header, various instruction combinations. Seconds ah.
There is a directive, is to modify, can also be summed up in the deletion of it, compared to people really put things to delete, and he is deleted directly into the insertion mode, like a flowing. The instructions to change the above can be used, the D all changed to C, easy to use, but also left a step into the insertion mode.
Yo West, to talk about the usage of a,i other places. In the code, you often have to modify (), [], "", "', {}" the contents of these pairs of symbols, such as you want to modify a function parameter list, such as fun (int a,int b), you want to change to other parameters, as long as the cursor in the () range, good, di) directly delete the contents of But still in the normal mode, press I, it can be modified, oops. What is not as direct CI), directly start the modification, fast one step, you can also VI), V is the choice to start the command, () the content is still in, but all anti-white, this time you can x delete, or y copy. Other brackets, quotes, and so on.

A If you are working with parentheses, you should delete all the options together.
Multi-layer nested parentheses ((a+b) *c), such as the case, if you cursor on the +, how to operate the inner layer or the outer parenthesis, such as to choose (a+b) *c, needless to say, I must be used, but only with VI) at this time will only choose A+b, then what method? To tell him to operate two layers, v2i), try, sure enough, v2a), the entire structure is selected, good magic.

A,i is a good helper to help me do a lot of things that I could not do before.

4, copy, paste

Y is copy, p is paste, y copy I don't know eh, p should be paste.

Often to do replication, in VS before copying a row has always been the cursor position nothing, CTRL + C, a line copy down, but also copied a line break, very convenient, VI provides easier operation, a finger operation, yy, copy a row, 2yy, copy the cursor position at the beginning of the 2 lines, and the Victory vs+ VA AH.

And then with the A,i brothers, Yaw can copy the current cursor in the word and after the word space, YIW also copy the word, but not including the following space.

Things copied good, where to paste good, this can be a headache, the first time the old will copy the wrong location, p will copy the good things in the line of the next row of the cursor, p will copy good things pasted in the line of the cursor on the row.

5. Regional selection

Described above, that is, V, press V, and then up and down can select the area, any move instructions can work, whether by word selection or by line selection.

Pressing V is the only way to move up and down, because he is the unit of action.

Vim in the press CTRL + V, you can make a special area selection, very fun, in VS, has been by ALT + mouse to select, here to remind, Linux words CTRL + c No problem, assuming that Windows Gvim, because and paste conflict, The command he replaced was ctrl+q, and the use of the Viemu plugin in VS was a long time to wonder. Children with obsessive-compulsive disorder can't afford to hurt themselves.

6. Undo, Redo

is the basic undo and redo of every software.

In VS with the habit of CTRL + Z and CTRL+Y,VI in the Undo command is U,redo is ctrl+r. Don't dwell on it.

7, the Assorted

What: wq:w: q:q! : SP XXX is basically not available under Windows. My head is thinking so much now, these are enough for the daily work, enough to write a Book VI handbook, I still do not look. Haha, all right, go to sleep.


This article is from the "Sai" blog, please make sure to keep this source http://saicom.blog.51cto.com/4355280/1612545

Linux Job Skills First: VI

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.