Teach you to learn Linux/unix under the vi text Editor

Source: Internet
Author: User
Tags file copy


The VI Editor is an editor that unix/linux system administrators must learn to use. Read a lot of information about VI, finally get this summary. First, remember the two modes of the VI Editor: 1,Command mode2, editing mode . After a unix/linux shell command or a VI command that starts with a slash (/), question mark (?), or colon (:), the user needs to type the ENTER key, and to switch to the VI command mode, you need to press ESC. Note that the VI command, starting with a colon (:) or slash (/), appears at the bottom of the screen, but no other commands appear on the screen.


Open, write, and close files (using the ENTER key)

ViFile Open file named files (UNIX shell command): W writes changes to the working buffer in the default file: Wfile writes the changes to the working buffer in files named: Q Exit VI Editor: WQ writes changes to the working buffer to file and exits: q! Do not write changes to the work buffer to the file and exit the VI editor

Insert text (used in VI command mode)A add text to the right of the current cursor position I insert text A at the end of the current cursor add text I at the beginning of the current line Add text o create a new line above the current line O Creates a new line below the current row R replace (overwrite) the current cursor position and a number of subsequent text J join cursor row and next line, become a row

Move CursorMove the cursor one position H left J down k up L right space bar right BACKSPAC to the left and right arrow keys to the direction shown E left Enter moves down to the beginning of the next line-(hyphen key) moves up to the beginning of the previous linecorrecting errors (used in VI command mode)X Delete a character dd delete the current line in the N line except the current row U undo last action (last step) U undo all operations on the current row

spell Check (UNIX shell command)SpellThe file display asks for the spelling errors found in the file.Ispell file display asks for the spelling errors found in the file

search (used in VI command mode)/word forward Search the first occurrence of Word/continue to search the next word? Word searches backwards for the first word that appears? Continue searching backwards for the next word

jumps to the specified line (vi command mode used)N+ forward (down) Jump N-row N-Backward (UP) Jump N-line NG jumps to row number n lines, g jumps to the bottom of the file for Go G

Set line number (used in VI command mode): Set NU Displays line number on screen: Set Nonu cancel line number

copy and paste (used in VI command mode)"Knyy copy n rows to buffer" K "KP pastes the contents of the buffer" K below the current line

Global replacement text (used in VI command mode):%s/old/new/g replaces all old in the file with new. s for substitution, the meaning of the substitution. G is global.

Edit another file (used in VI command mode): Eotherfile editing files with file name Otherfile

Develop an editor for command-line editing (UNIX shell command)Bindkey-v Specify VI editor (for TCSH) visual=vi Specify VI editor (for ksh) Set-o VI Specify VI Editor (for bash)

buffers:As I said earlier, the VI editor is designed to edit the file copy of the working buffer. When using the VI editor, users can also access other buffers.  There are a total of 36 buffers. Unnamed buffers named buffers "A," B, "C 、......、" Z numbered buffers "1," 2, "3 、......、" 9 unnamed buffers are sometimes called general buffers. When the text is modified, the old text is not immediately deleted. VI places the old text in an unnamed buffer until the user deletes the modified text. This allows for revocation, and the specific command is U. Because VI has only one unnamed buffer, it can only be undone once.

Switch between command mode and edit mode:

If you do not know the current mode, you can press the ESC keyboard 2 times in a row, the host will make an alarm sound, so you must enter the command mode. Under command mode, input a a i i o o r will enter edit mode. The individual characters you enter are not displayed and are not inserted into the file.


This article is from "Eric Chen" blog, please be sure to keep this source http://skycyc23.blog.51cto.com/231267/352596



Teach you to learn Linux/unix under the vi text 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.