In advance, I have a Linux rookie, but even the rookie, but also to keep a good study, day-to-day heart. I've been studying CentOS in my spare time. Often to view, edit files, surf the internet and see the Vim. The text editor used is VI, a recent study of CentOS, on-line search for tutorials mentioned with Vim. Vim is the VI improved (enhanced version of VI). So the function is more powerful, not much else to say. For Linux novices, editing text is most often used to open text, edit, move the cursor, save the edited text, and so on. Here's a quick introduction:
Open the text. This is very simple.
For example: open hostname This file, you only need to enter in the command line:
[Email protected]]# Vim/etc/hostname
650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/> Enter it, hostname this file opens, And you can see what's inside.
2. Text mode.
There are two modes of vim:
-Normal Mode
-Edit mode
By default you open the text vim is in normal mode, that is, the browsing mode, is not editable, you can only see, can not be edited, do not believe you enter characters randomly try. Of course, except for I this special character, because this character is to enter the editing mode shortcut key.
3. Enter edit mode.
As described in 2, in normal mode, press the I key to enter edit mode. This time you will be able to enter the normal changes.
Tips:vim support keyboard on the upper, lower, left and right arrow keys, while VIM has its own upper and lower lines and left and right cursor movement of the shortcut keys, that is H, J, K, l these 4 keys, because in the keyboard is continuous, it is very convenient to operate, of course, for the people just contact, may be a little unaccustomed, But it's easy when you're skilled.
4. Save the exit.
After editing the text, the most important thing is to save and exit. You want to save the edited content, so to do:
-Exit Edit mode: Press ESC directly to exit edit mode.
-If you enter
:w carriage return ( Save the edited file contents, but do not exit vim Editor. )
: Wq Enter ( after saving the contents of the file, exit the vim Editor.) )
: w! Enter ( forces the file to be written, that is, to overwrite the original file. This command can be used to force writes if the original file's access permission does not allow writing to the file, for example, if the original file is a read-only file. )
: wq! Enter ( forces the file contents to be saved and exit the vim Editor.) )
That's all! Hope to help children! You're welcome! Please call me Lei Feng! 650) this.width=650; "src=" Http://img.baidu.com/hi/tsj/t_0021.gif "alt=" T_0021.gif "/>
Some of the most common commands for VIM