Note content:
L 5.1 Vim Introduction
L 5.2 Vim color display and move cursor
L 5.3 Vim general mode move cursor
L 5.4 Vim general mode copy, cut and paste
Note Date:2017.8.4
5.1 Vim Introduction
Vim is a similar toViThe well-known powerful, highly customizableText Editor , on the basis of VI to improve and add a lot of features. Vim isfree software. Vim is fromVI developed a text editor. Code completion, compilation and error jump and other convenient programming features are particularly rich, widely used in programmers, and Emacs parallel to become Unix-like,LinuxFavorite text Editor for system users.
650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M00/08/64/wKiom1ngle-D1kP2AAr6zPZbZRA768.png "style=" float : none; "title=" vim introduction with some use way 589.png "alt=" Wkiom1ngle-d1kp2aar6zpzbzra768.png "/>
1. If your operating system does not have vim, you can install the yum install-y vim-enhanced command:
650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M01/A7/1B/wKioL1ngkz2wIJ6HAAfZJnsXRC0535.png "style=" float : none; "title=" vim introduction with some use way 644.png "alt=" Wkiol1ngkz2wij6haafzjnsxrc0535.png "/>
2.vim is displayed with color when viewing text, e.g. I use vim to open the passwd in the etc directory file:
650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M01/08/64/wKiom1nglfjiQcdRAAuw-w0222I047.png "style=" float : none; "title=" vim introduction with some use way 691.png "alt=" Wkiom1nglfjiqcdraauw-w0222i047.png "/>
3. The general mode of Vim is that you have not pressed i into the edit mode, in general mode you can copy and paste lines and Delete a row using DD.
4.Vim 's editing mode, is to press the i or a key to enter the file editing status, be able to edit the contents of the file.
5.Vim 's command mode is to use a similar less command to operate the file, including using Wq to Save the exit,Q exit and q! forced exit, and so on, these are in command mode.
5.2 Vim color display and move cursor
by using vim above to view the passwd file , vim is shown with color, but if the passwd Files are copied to another directory, you will find that using vim to view but there is no color, such as I copied to the tmp directory:
650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M02/A7/1B/wKioL1ngk0ewGHSdAAsMKo9Hvu4131.png "style=" float : none; "title=" vim introduction with some use way 952.png "alt=" Wkiol1ngk0ewghsdaasmko9hvu4131.png "/>
etc tmp etc The file below is not displayed in the other directory is also normal color.
let's look at another example, I copy the fstap file from etc to the tmp directory, and then use vim to view:
650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M00/A7/1B/wKioL1ngk0uRNARZAAjHAw4rnJQ415.png "style=" float : none; "title=" vim introduction with some use way 1100.png "alt=" Wkiol1ngk0urnarzaajhaw4rnjq415.png "/>
you can see that the files under etc can also display color under TMP, because the top content of the fstab file has a # number at the beginning, if the passwd The file also adds a few lines to # The contents of the number, the lines will also display color:
650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M01/08/64/wKiom1nglgPi5uZiAAS3rzvbTiA598.png "style=" float : none; "title=" vim introduction with some use way 1195.png "alt=" Wkiom1nglgpi5uziaas3rzvbtia598.png "/>
This means that the file itself is not without color, but the content of the file does not have the condition to display the color.
not only can display the color according to the file content, but also can make the file content display color according to the file's name, for example I changed passwd to passwd.sh:
650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M01/A7/1B/wKioL1ngk1GxyVnwAAkvGBzjcSw408.png "style=" float : none; "title=" vim introduction with some use way 1294.png "alt=" Wkiol1ngk1gxyvnwaakvgbzjcsw408.png "/>
The configuration file for Vim is vimrc in the etc directory:
650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M02/08/64/wKiom1nglgyRAWTBAArPc3tD4eY540.png "style=" float : none; "title=" vim introduction with some use way 1358.png "alt=" Wkiom1nglgyrawtbaarpc3td4ey540.png "/>
Vim 's more advanced usage can be configured in this configuration file, such as code highlighting, automatic indentation, and so on.
5.3 Vim general mode move cursor
650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M02/A7/1B/wKioL1ngk12SvZDxAA3TcksQGXw846.png "style=" float : none; "title=" vim introduction with some use way 1416.png "alt=" Wkiol1ngk12svzdxaa3tcksqgxw846.png "/>
Add: When using the key to move the cursor, plus a number, you can use this number to move how many characters.
650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M00/08/64/wKiom1nglhmD1FqIAAzJUkmrutc460.png "style=" float : none; "title=" vim introduction with some use way 1463.png "alt=" Wkiom1nglhmd1fqiaazjukmrutc460.png "/>
5.4 Vim general mode copy, cut and paste
650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M02/08/64/wKiom1nglh-hTiPuAAufmLRHsD4607.png "style=" float : none; "title=" vim introduction with some use way 1489.png "alt=" Wkiom1nglh-htipuaaufmlrhsd4607.png "/>
650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M00/A7/1B/wKioL1ngk3LCfEiTABKafIJ6syo826.png "style=" float : none; "title=" vim introduction with some use way 1491.png "alt=" Wkiol1ngk3lcfeitabkafij6syo826.png "/>
650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M00/A7/1B/wKioL1ngk3XRYrpnAAVpJnLHRlA889.png "style=" float : none; "title=" vim introduction with some use way 1494.png "alt=" Wkiol1ngk3xryrpnaavpjnlhrla889.png "/>
This article is from the "12831981" blog, please be sure to keep this source http://12841981.blog.51cto.com/12831981/1972191
Introduction to VIM and some ways to use it