How to use the VIM editor

Source: Internet
Author: User

introducing the next Wim,Vim is a well -known, powerful, highly customizable text editor similar to VI, which improves and adds a lot of features on the basis of VI. VIM is purely free software.

Vim is generally respected as the best of the class Vi editor, in fact the real rivals come from different variants of Emacs. 1999 Emacs was selected as the winner of the LinuxWorld text editing category andVim was second. But in the year 2 , Vim won Slashdot Beanie 's best open source text editor Jackpot and pushed Emacs to the second line , on the whole , Vim and Emacs are also very good text editors.

The Wim is a modal editor with three modes:

Edit mode is also known as command mode

Input mode

Last-line mode

The function of each mode is not the same, when we open the text is in the editing mode, the following is how to go into the input mode in edit mode.

Edit mode----> Input mode:

I: Insert, into input mode

A: Append

O:

I: The beginning of the line

A: End of line

O: Up and down new CCB

Input mode----> Edit mode:

We cannot go directly from input mode to edit mode, we need to intervene the ESC key first.

Edit mode----> Last-line mode:

Moving from edit mode to the last line mode involves ":" To enter the last line mode.

Last-line mode----> Edit mode:

The ESC key can be entered from the last line mode to the edit mode, but vim cannot directly enter into the input mode from the last line mode, and must first go to edit mode in the input mode.

Open the VIM editor

There are two ways to open the VIM editor

#vim Open directly

#vim/etc/sysconfig/network//Follow the path name and need to open the file

To close the VIM editor:

#:q! Force quit, everything you do is not saved

#:wq//Save changes

Here's what VIM uses:

use VI to open the Install.log file in the current directory , using 6 Different instructions to enter the editing state ( Note that 6 different ways to enter the editing state, Where the cursor is located )

The first kind of use I

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/72/BA/wKiom1Xr-4PSLmccAACJ01SAzRA505.jpg "title=" 1.jpg " alt= "Wkiom1xr-4pslmccaacj01sazra505.jpg"/>

The second type uses a

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/BA/wKiom1Xr-5Ch6hczAABtHzsh6NE582.jpg "title=" 2.jpg " alt= "Wkiom1xr-5ch6hczaabthzsh6ne582.jpg"/>

The Third Kind uses o

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/72/B6/wKioL1Xr_cGgG3K9AABzGHl7ZmY049.jpg "title=" 3.jpg " alt= "Wkiol1xr_cggg3k9aabzghl7zmy049.jpg"/>

The fourth kind uses O

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/72/BA/wKiom1Xr-6Ty40zPAABg-cEeN28723.jpg "title=" 4.jpg " alt= "Wkiom1xr-6ty40zpaabg-ceen28723.jpg"/>

The fifth kind uses I

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/72/B6/wKioL1Xr_dbRgMYxAABnSFMqeIg135.jpg "title=" 5.jpg " alt= "Wkiol1xr_dbrgmyxaabnsfmqeig135.jpg"/>

The sixth kind uses A

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/B6/wKioL1Xr_d-g-5NvAAB1VHwcDd0327.jpg "title=" 6.jpg " alt= "Wkiol1xr_d-g-5nvaab1vhwcdd0327.jpg"/>

Returns the instruction state, using the instruction to move the cursor to the end of the current line, and then using the instruction to move the cursor to the beginning of the current line

with 0 or $ to move the beginning of the line end

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/B6/wKioL1Xr_fDDtkU4AACgl4TtpHc470.jpg "title=" 7.jpg " alt= "Wkiol1xr_fddtku4aacgl4ttphc470.jpg"/>

Use directives to move the cursor to the middle row of the current window

with M To move the current window's cursor to the middle row

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/72/B6/wKioL1Xr_fnDGaTxAACXeUcbSYE669.jpg "title=" 8.jpg " alt= "Wkiol1xr_fndgatxaacxeucbsye669.jpg"/>

Use directives to move the cursor to the end of the current window

with L to move the window cursor to the end of the window

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/BA/wKiom1Xr-__wIu3yAABwJpEr0zM145.jpg "title=" 9.jpg " alt= "Wkiom1xr-__wiu3yaabwjper0zm145.jpg"/>

Use instructions to move the cursor to the end of the entire file

with G moves the cursor to the end of the file

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/72/B6/wKioL1Xr_jHyIAaSAABuhxfdbUY199.jpg "title=" 10.jpg "alt=" Wkiol1xr_jhyiaasaabuhxfdbuy199.jpg "/>

Use directives to move the cursor to the first row of the current window

with H instruction moves the cursor to the first row of the current window

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/72/BA/wKiom1Xr_BThlhi8AACDt3wtwTY087.jpg "title=" 11.jpg "alt=" Wkiom1xr_bthlhi8aacdt3wtwty087.jpg "/>

In instruction state, use directives to delete the contents of the cursor at the beginning of the line

with D0 instruction to delete the content at the beginning of the cursor

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/72/BA/wKiom1Xr_B7Abws9AABwUuCtW3g585.jpg "title=" 12.jpg "alt=" Wkiom1xr_b7abws9aabwuuctw3g585.jpg "/>

In instruction state, use directives to delete the contents of the cursor at the end of the line

with D $ instruction to delete the content at the end of the cursor

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/72/BA/wKiom1Xr_DrTFLy4AACiQ4v3jm8072.jpg "title=" 13.jpg "alt=" Wkiom1xr_drtfly4aaciq4v3jm8072.jpg "/>

In the instruction state, cut the current line, and then move the cursor to the end of the file to paste

with DD command to cut the current line, using the P instructions to paste

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/B6/wKioL1Xr_m7g07BrAABR1caL_sc902.jpg "title=" 14.jpg "alt=" Wkiol1xr_m7g07braabr1cal_sc902.jpg "/>

In the instruction state, copy the current line, and then move the cursor to the end of the file to paste

with yy command to copy the current line, using the P instructions to paste

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/BA/wKiom1Xr_E-QTWGjAAB3xCaH8SU524.jpg "title=" 15.jpg "alt=" Wkiom1xr_e-qtwgjaab3xcah8su524.jpg "/>

in instruction state, copy 5 lines from the current line to the end of the file

with Nyy Copy 5 line to end of file

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/72/BA/wKiom1Xr_FqxWsgsAABNfIDN2vY996.jpg "title=" 16.jpg "alt=" Wkiom1xr_fqxwsgsaabnfidn2vy996.jpg "/>

in instruction state one, cut 5 lines from the current line to the end of the file

with NDD Cut 5 line to end of file

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/72/BA/wKiom1Xr_GSwdiZVAABJXUo7ogE392.jpg "title=" 17.jpg "alt=" Wkiom1xr_gswdizvaabjxuo7oge392.jpg "/>

Switch to last line command state

Display the line number of a file using the last line command

with Set Nu Show file line number

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/BA/wKiom1Xr_G6BdyinAAArnTTt64E842.jpg "title=" 18.jpg "alt=" Wkiom1xr_g6bdyinaaarnttt64e842.jpg "/>

In the last command state, move the cursor quickly to the beginning of the file.

with 0 command to quickly move the cursor to the beginning of the file

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/72/B7/wKioL1Xr_qiwwGorAACWFyVqzCM926.jpg "title=" 19.jpg "alt=" Wkiol1xr_qiwwgoraacwfyvqzcm926.jpg "/>

in the last command state, Copy the contents of line a to Line No.

with Co command Replication

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/72/B7/wKioL1Xr_rSw4wxHAABtL4G7pGU061.jpg "title=" 20.jpg "alt=" Wkiol1xr_rsw4wxhaabtl4g7pgu061.jpg "/>

in the last command state, move line 1 to Line 5 to page

with Mo Command Move

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/72/BA/wKiom1Xr_Jfyi7nfAACMUJrAGaM942.jpg "title=" 21.jpg "alt=" Wkiom1xr_jfyi7nfaacmujragam942.jpg "/>

in the last command state, delete the contents of line I to

with N , MD Delete Content

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/B7/wKioL1Xr_smh3QfyAACNqX3NJ3s829.jpg "title=" 22.jpg "alt=" Wkiol1xr_smh3qfyaacnqx3nj3s829.jpg "/>

in the last command state, quickly move the cursor to the beginning of the file to find all the "Setup" characters in the file

with /* Find characters

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/72/B7/wKioL1Xr_tTBkSv3AABVRr2Io6E559.jpg "title=" 23.jpg "alt=" Wkiol1xr_ttbksv3aabvrr2io6e559.jpg "/>

in the last command state, replace all "Installing" in the file with"Xinhua"

with 1 , $s/instaling/xinhua replace

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/72/B7/wKioL1Xr_uPh24tXAABkdqwymRk164.jpg "title=" 24.jpg "alt=" Wkiol1xr_uph24txaabkdqwymrk164.jpg "/>

Hide line numbers with last line command

with Set Nonu Command

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/72/BA/wKiom1Xr_MXSjRQjAACR-aK6jDo757.jpg "title=" 25.jpg "alt=" Wkiom1xr_mxsjrqjaacr-ak6jdo757.jpg "/>

do not save forced exit V

with Q ! Command

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/B7/wKioL1Xr_viSPnL6AABJ2Wg79vQ880.jpg "title=" 26.jpg "alt=" Wkiol1xr_vispnl6aabj2wg79vq880.jpg "/>

Vim has a built-in editing practice, you can also go to use, called Vimtutor. Input can be related to the tutorial, if you install the Linux is Chinese, then the tutorial will show the Chinese manual.

This article is from the "8430482" blog, please be sure to keep this source http://8440482.blog.51cto.com/8430482/1691972

How to use the VIM editor

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.