1.VI and Vim
In the world of Linux, most of the configuration files are in ASCII Plain text form, so the use of simple text editing software can be modified settings!
It's often heard: Emacs, Pico, Nano, Joe, and Vim, and so on (note 1).
Use of 2.VI
Basically, vi is divided into three modes, namely, " General mode", " edit mode" and " command-order mode". The three modes of action are:
- General mode:
Open a file with VI directly into the general mode (this is the default mode).
- Edit mode:
In general mode can be deleted, copied, pasted and so on, but can't edit the contents of the file! Wait until you press "I, I, O, O, A, a, R, R," and any one of the letters before entering edit mode.
- Instruction-column Command mode:
In the general mode, enter " :/? "Any one of the three buttons, you can move the cursor to the bottom row." In this mode, you can provide "search data" action, and read, save, a large number of substitution characters, leave VI, display line number and so on the action is achieved in this mode!
2.1 Key Instructions
- Part I: General mode available button description, cursor movement, copy paste, search substitution, etc.
- Part Two: General mode switch to edit mode available button description
- Part III: General mode switch to instruction column mode available button description
3.DOS and Linux break characters
Because the break characters and DOS are different from the definition of some characters under the Linux operating system, it is not recommended that you upload the files to the Linux system after editing them in the Windows system, which is prone to error problems. Also, if you copy some plain text files between different systems, remember to use Unix2dos or Dos2unix to convert the break format!
Key reviews
- Linux under the configuration file is more text files, so use Vim can be set to edit;
- Vim can be regarded as the program editor, can be used to edit shell script, configuration files, etc., to avoid typos;
- VI for all UNIX like operating systems will exist in the editor, and execution speed;
- VI has three modes, the general mode can be transformed to edit and command column mode, but the editing mode and the command column mode is not interchangeable;
- Commonly used keys are I, [ESC],: WQ, etc.;
- The picture of VI can be divided into two parts, (1) The upper part of this article and (2) The last line of the state + instruction column mode;
- The number is meaningful to illustrate the meaning of repeating several actions, such as 5yy for copying 5 lines of meaning;
- In the movement of the cursor, uppercase G is often used, especially 1G, G moves to the head/tail function of the article!
- VI's replacement function is also very good! : N1,n2s/old/new/g should pay special attention to study;
- Decimal point ". "To repeat the previous action, is also a frequent use of the key function!"
- Enter edit mode almost as long as remember: I, O, R three buttons can! In particular, the addition of a new row of O vs. substituted R
- VIM will actively set up a swap file, so don't disconnect!
- If there is an aligned chunk within the article, you can use [ctrl]-v for copy/paste/delete behavior
- Use: SP function to split windows
- The environment setting of Vim can be written in ~/.VIMRC file;
- You can use Iconv to convert the file language encoding
- Using Dos2unix and Unix2dos, you can change the line-breaking character for each line of the file.
Brother Bird's Linux private cuisine Learning-(10) Vim program editor