1、文件编辑器 vi(VI file editor)VI file editorAuthor: North South SouthFrom: LinuxSir.OrgAbstract: VI editor is the most commonly used document creation and editing tools, beginners should learn the simple application of VI, learn to do a simple modification, delete, insert, search and replace operations in
2、 VI; if you are a novice, look at this simple operation, perhaps this document allows you to learn VI in the shortest time in;Catalog1, a text editor;2, VI editor;Method of use 3, VI editor;3.1 how to call vi;Three command mode 3.2 vi;Save the file and exit 3.3;3.4 cursor;3.5 insert mode (text inser
3、tion);Delete the text 3.6;3.7 modify and delete operation recovery recovery;3.8 visual mode;3.9 copy and paste operations;On line number 3.10;3.11 find and replace function;3.11.1 search;3.11.2 replacement;4, about the;5, postscript;6, reference documentation;7, the relevant documents;+text+1, a tex
4、t editor;There are a lot of text editor, such as GEDIT, kwrite, graphical model, OpenOffice text mode editor VI, VIM (enhanced version of VI) and nano VI and VIM we are most commonly used in the Linux editor. It is necessary for us to introduce VI (VIM) is the most simple usage, in order to make the
5、 Linux entry level users learn to use it in the shortest time.Nano tools and DOS operating system under the edit operation is similar, easy to use, we should not be introduced, if you are interested, may wish to try;2, VI editor;Why should learn the simple application of VIVI or VIM Linux is the mos
6、t basic text editing tools, VI or VIM although there is no graphical interface editor that simple mouse operation, but the VI editor in system management, server management, always not a graphical interface than the editor. When you do not have to install X-windows desktop environment or desktop env
7、ironment collapse, we still need a character mode editor vi;VI or VIM editor to create and edit the document in the simple and efficient tool;Method of use 3, VI editor;3.1 how to call vi;rootlocalhost VI filename #Three command mode 3.2 vi;Command (command) mode for input command;Insert (insert) mo
8、del for inserting text;Visual (visual) model for visual and highlight selected text;Save the file and exit 3.3;Command mode is the default of VI or VIM, if we are in other command mode, through the ESC switch.When we press the ESC key, then input: No., VI will at the bottom of the screen waiting for
9、 us to enter the command;Save: w;W filename: save as filename;: wq!Save and exit;Note: WQ! Filename: in the filename file and exit;Exit without saving: Q;X should be out, and the preservation of function and the same: WQ!3.4 cursor;When we entered the Command model by ESC, we can use some of the fol
10、lowing keys to move the cursor;J move down the line;K moves up one line;H move one character to the left;L move one character to the right;Ctrl+b moving up a screen;Ctrl+f move down the screen;The up arrow to move;The down arrow to move downward;Move the left arrow to the left;Move the right arrow t
11、o the right;We edit a file, for J, K, l and H keys, but also in front of the action command with numbers, such as 3j, said the downward movement of 3 lines.3.5 insert mode (text insertion);I in the cursor before inserting;A in the insert cursor;I cursor row insert;A in line the cursor is inserted at
12、 the end of the line;O cursor for the above insert a row;O under the cursor for inserting a row;S delete a character after the cursor, then enter insert mode;S delete the cursor, then enter insert mode;Delete the text 3.6;X a character;#x delete several characters, # said numbers, such as 3x;DW dele
13、te a word;#dw delete the words # with digital representation, such as the 3dw delete three words;DD delete line;#dd delete multiple rows, # represent numbers, such as 3dd and delete the cursor cursor line two line;D$cursor to the end of the content;J cursor located on the line between the lines and
14、spaces, the cursor and a line connected together;3.7 modify and delete operation recovery recovery;U undo modify or delete operation;Press the ESC button to return to the Command (command) mode, and then press u to undo delete or modify the previous; if you want to undo a previous modify or delete o
15、peration, please press the press several times U. The Word and undo operation is not much difference;3.8 visual mode;In the latest Linux release, VI provides a visual mode, because this function is only vim. If you use the VI does not have this feature, it has replaced vim. Open the video mode, pres
16、s the ESC key, and then press V to enter visual mode;The visual pattern provides a very friendly selection range of text for us to highlight; in the bottom of the screen shows;- VIDEO -or-VISUAL-Figure:Enter visual mode, cursor movement commands we can say in front of the command line mode, you can
17、select a range of text.What is the use of selected text?We can delete the job of a part, press the D button to delete the selected content we.The selected content, we just press y said copy; press D delete;It is worth mentioning is deleted at the same time, also said copy.We return to the command mo
18、de, and then move the cursor to a location, and then press the shift+p key, just delete the content posted. We here mention that in the following, we have to explain in detail.From the visual mode, or use the ESC key;3.9 copy and paste operations;In fact, delete it with shear mean, when we delete th
19、e text, can move the cursor to the place, and then press shift+p to paste the contents in the same place, and then move the cursor to the place, and then press P or shift+p to paste;P cursor paste;Shift+p in the paste before the cursorTo give an example:For example, we want to get a document for thi
20、rd Posts copied down, then back to the fifth line, what should we do?There are two kinds of methods;The first method:The first third rows to delete, move the cursor to the third line, and then use the DD action, then click shift+p. This is just the third line delete posts in the place.Then we use th
21、e K keys to move the cursor to the fifth line, and then press the P button, the third row to the fifth row of the posts and content behind;Second kinds of methods;Enter visual mode, press the ESC key, and then press v. Move the mouse pointer, select the third row of the content, and then press y to
22、copy; then move the pointer to the fifth row, then press P key;So a copy and paste operation, command mode, insert mode and visual mode of comprehensive application; we want to switch between different mode of society, should be used ESC key; more important to learn how to move the cursor in command
23、 mode;On line number 3.10;Sometimes we configure a program runs, there will be errors for X configuration file. Then we will use the relevant operation line;Add the line number for all content;Press the ESC button, and then enter the:Set: numberThe cursor positionIn the lower right corner of the scr
24、een, there are similar to the following;57,8 27%In this, the 57 said fifty-seventh, 8 said eighth characters;3.11 find and replace function;3.11.1 search;First of all, we have to enter the ESC key, enter the command mode; we input / or enter the search mode?;/SEARCH note: positive search, press the
25、N key to move the cursor to the place to meet the conditions of the next;SEARCH? Note: the reverse lookup, press the shift+n key to move the cursor to the next eligibleFor example: for example, I want to find the swap word in a file, I should do as follows;First, press the ESC button, and then enter
26、 into the command mode;/swaporSwap?3.11.2 replacement;Press the ESC key to enter command mode;S /SEARCH/REPLACE/g: Note: the current cursor position in the word SEARCH, replaced by REPLACE, and all SEARCH highlighted;%s /SEARCH/REPLACE: Note: replace all SEARCH documents into REPLACE;#, #: s /SEARCH
27、/REPLACE/g note: No. No. said the figures, said to number of lines from the number of lines, replace SEARCH with REPLACE;Note: in this, G said the global search; we note that there is no alternative place, will also highlight SEARCH;For example:For example, we have to modify a document;We put the cu
28、rsor, put all the words the, THE should be replaced:S: /the/THE/gWe put the whole document all the the THE should be replaced:%s: /the/THEWe are merely first to tenth lines in the, THE should be replaced;1,10: s /the/THE/g4, about the;I write the purpose of this paper is to let the novice in the sho
29、rtest time with VI or VIM to create, edit and modify the file, so that this document is not large and the VI manual. If the VI are all full, at least write a thousand pages of books; this does not involve more advanced usage of vi. If you want to know more, please find the man and help;5, postscript
30、;So far, about the directory and file operations, I wrote a few articles, from the file and directory to create, delete, copy to the property operation, and finally to modify the document file. These documents are relevant, if connect these related documents, is a whole piece of knowledge. We only g
31、rasp the knowledge, to achieve the file system management.In the future I will write what content? May add files to find, in fact before a similar document, I summarize, posted for everyone to see it.The next step is to prepare the document network infrastructure construction, network infrastructure is more important, this is my plan for the next key6, reference documentation;Man VI and VI -help7, the relevant documents;