CentOS Fragmented Learning 14.

Source: Internet
Author: User

The use of VI or vim place more and more, today share------VIM usage------

Vim as a VI upgrade, compared to the advantages of vi obvious, color marker highlighting the distinction, are to provide a better visualization.

Vim requires Yum to install (command)

# yum Install-y vim

In fact, VIM has its own package, let's show it with Yum list

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6E/29/wKioL1V1gemhbA1pAADdy3d8F7s439.jpg "title=" 5.png " alt= "Wkiol1v1gemhba1paaddy3d8f7s439.jpg"/>

That is, the 32-bit system that vim-enhanced I used, naturally. i686


Let's take a look at the difference between Vim and VI in the display.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6E/58/wKiom1V5alHT703NAAI4mN7agTc278.jpg "title=" 7.png " alt= "Wkiom1v5alht703naai4mn7agtc278.jpg"/>

Vim and VI is an upgrade version of it, first to introduce the three mode (vi is also applicable)

    1. General mode

    2. Command mode

    3. Edit mode


General mode to introduce common usage

Common shortcut keys

The H-J K L is the first to look at the keyboard, respectively.

K Move Cursor up

J Cursor moves down

H Cursor Line moves forward

L move backwards on the line of the cursor


If you want to screen one screen page to remember the following two shortcut keys

Ctrl+fb

Ctrl+f PAGE Down

Ctrl+b PAGE Up


Want to jump straight to the beginning using GG

To jump directly to the end of a file, use G.


The number plus g can specify to jump to the first few lines

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6E/55/wKioL1V5eN2h12NaAAE_akUwbp4205.jpg "title=" 8.png " alt= "Wkiol1v5en2h12naaae_akuwbp4205.jpg"/>

It's the result of my 6+g.


The line number below the bottom row uses the Set Nu

Cancel line number bottom row use Set Nonu


Let's look at a picture like this.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6E/55/wKioL1V5evDBBF2PAACxTRgOcqU572.jpg "title=" 9.png " alt= "Wkiol1v5evdbbf2paacxtrgocqu572.jpg"/>

At this point the cursor is in the middle, and you want to jump to the beginning of the line (non-whitespace character)

^ symbol is shfit+6

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6E/55/wKioL1V5e7HRRobHAADY9jexXVo244.jpg "title=" 10.png "alt=" Wkiol1v5e7hrrobhaady9jexxvo244.jpg "/>

Same

The $ symbol is shift+4 jumps to the end of the line


As you can see, there is a gap in the example above, and I want to jump to the blank position at the beginning of the front.

You can use the number 0 to jump to the front of the blanks

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6E/59/wKiom1V5eqajgJqeAADMHjHK7A8965.jpg "title=" 11.png "alt=" Wkiom1v5eqajgjqeaadmhjhk7a8965.jpg "/>


In fact, the general mode can also complete the Cut copy and paste

First look at the cut and paste of individual characters

First look at the original

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6E/55/wKioL1V5fhLSDxA_AABeA0IMOew459.jpg "title=" 12.png "alt=" Wkiol1v5fhlsdxa_aabea0imoew459.jpg "/>

Look what I've done.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6E/55/wKioL1V5fqPwftfyAABdtL-1dOo929.jpg "title=" 13.png "alt=" Wkiol1v5fqpwftfyaabdtl-1doo929.jpg "/>

Actually use X key, cut p key to paste

X key is the cursor is cut off one character P key is also a character after pasting

X key is the use of the cursor to cut off a character P-key forward


and the whole line of cut DD same p key paste look at the picture

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6E/55/wKioL1V5gQvQTAC-AADDGBG9lM0496.jpg "title=" 14.png "alt=" Wkiol1v5gqvqtac-aaddgbg9lm0496.jpg "/>

The following are the operating

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6E/55/wKioL1V5gWLAWtzNAADA5saxgZo173.jpg "title=" 15.png "alt=" Wkiol1v5gwlawtznaada5saxgzo173.jpg "/>

In addition to the single-line DD can also be number +DD specify the number of lines cut to see instances

This picture is the one before the cut.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6E/59/wKiom1V5gRPj4QJqAAHdiG2o4Kk826.jpg "title=" 16.png "alt=" Wkiom1v5grpj4qjqaahdig2o4kk826.jpg "/>

Here is the 5 line position after pasting has changed significantly.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6E/59/wKiom1V5gSmQggECAAI3zsGrpx8163.jpg "title=" 17.png "alt=" Wkiom1v5gsmqggecaai3zsgrpx8163.jpg "/>

Now, say a word. Copy and paste

Copy yy paste shine or P number +yy you can specify a few lines to copy

Look at the picture before copying

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6E/59/wKiom1V5g-yz7xb3AANijKpqVUg447.jpg "title=" 18.png "alt=" Wkiom1v5g-yz7xb3aanijkpqvug447.jpg "/>

Post-paste Results

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6E/55/wKioL1V5haySlxhGAAMpNpSW2os513.jpg "title=" 19.png "alt=" Wkiol1v5hayslxhgaampnpsw2os513.jpg "/>


In edit mode

I insert in front of the cursor

I Insert at the beginning of this line

A current cursor positioned behind insert

A to the end of this line write something new

o Another line below the cursor line

O start another line above the cursor line

ESC exits


I and a can look at the following example to see the red box price

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6E/55/wKioL1V5hxDynmyOAAD52QPdND8656.jpg "title=" 20.png "alt=" Wkiol1v5hxdynmyoaad52qpdnd8656.jpg "/>

The above is the I key edit

Here is a key edit


I and A are also examples of demonstration note look at the red box mark

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6E/59/wKiom1V5hg3CDVv9AADDE5T3Oik735.jpg "title=" 21.png "alt=" Wkiom1v5hg3cdvv9aadde5t3oik735.jpg "/>

The above is the I key edit

Here is a key edit


O and O are also see the example demo note the Red box mark

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6E/55/wKioL1V5imOyjYktAAGU77hkEPs724.jpg "title=" 22.png "alt=" wkiol1v5imoyjyktaagu77hkeps724.jpg "/> Above is the result of the O key

The following is the result of the O key


You can also search for keywords in vim.

Directly below the bottom line/or? Add keyword so you can highlight the display

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6E/55/wKioL1V5jLijSTTFAAR2ewfjUo4850.jpg "title=" 23.jpg "alt=" Wkiol1v5jlijsttfaar2ewfjuo4850.jpg "/>

Use Shift+n to toggle highlighted keywords


How do I cancel a highlighted keyword? Use: Nohl

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6E/59/wKiom1V5i7-B80wVAADH2mmDJcM521.jpg "title=" 24.png "alt=" Wkiom1v5i7-b80wvaadh2mmdjcm521.jpg "/>


The use of VIM is actually more practice and good.








CentOS Fragmented Learning 14.

Related Article

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.