Vi Command Learning

xiaoxiao2021-03-06  86

Vi Command Learning

VI is one of the standard text editors in UNIX.

The command is case sensitive in the VI, and the working mode is divided into insertion and command mode. The command mode includes basic commands and EX editing commands, and the EX editing commands generally appear under the screen, by: lead.

VI command format: [Command] (text) [Command] (Digital) (Digital) [Command] (Text)

Basic command: i a c D y p u x w q o R

VI [filename] Opens a specified file Basic text Processing I Insert text in front of the current cursor, insert text a on the leader, insert text a after the current cursor One line X Delete Current Sports Character XW Delete Word X $ Delete to Row Tail X0 Delete to Line 5X Delete 5 Character 0 Cursor Move to Current Row First Character $ Cursor Move to the Last Character H Cursor Left Move Zone One Space l Move the cursor right to move a space J code to move a row of K curst to move a row of W | W Cursor Previous Word B | B cursor After moving a word P Paste Move or copy text can be removed (DD), then paste (P) Method implementation, such as DD deletion, P paste, X delete characters, p paste characters. C | c Modify the text CW to modify the word, and insert the C $ modified to the row c0 to modify the lead CC Replace the current row D | D Delete character DW Delete Word D $ Delete to the line DD Delete Current Row R | R Replace the current text S Replace the current row S replace characters ~ letter case translation Y | Y copy text YW Copy Word Y $ Copy to the line Y0 Copy to the list of YY Copy a line 4yy copy 4 lines. Repeat operation U Underated the last operation U withdraw any Operation J combined with the current line and the next line parameters can be used, such as 4h left shift 4 spaces, 50i * insert 50 * / | n forward search? | N to search after search ^ f forward roll forward one screen ^ b After rolling one screen ^ D forward roller half screen ^ U back half screen ^ l Refresh screen Edit Command Extension VI [file] Open file to the last line Vi -r [file] system crash after recovery file VI N [ FILE] Open file to NPVI / PATTERN [File] Open file to the mode the first place VI -R Open files in read-only mode // 1-9 Delete operation VI editor Ctrl Z Hang a VI, return to the UNIX shell status, do other work, the FG command in the UNIX shell allows the current job to return the first pending VI window EX line editor VI, can be used in the EX line command! Call the UNIX system command Such as! Ls, list all the files of the current directory,! DF looks at the current hard disk usage. The EX command consists of the line number and command, and the Enter key ends.

: 1 to the first line: 1, 3 Print 1 ~ 3 lines: $ to the last line: SHIFT G to the last line: P Recovered the contents of the buffer (eg 1P: 3P): S / Screen / Line Replace the current line The first Screen is line: 1, 3 s / screen / l Replace 1 to 3 rows of Screen to LQ into the EX Editing Command Mode VI Return VI Editor: Delete | D Delete: Copy | Co | T Copy and Paste COPY Content: Move [Line Number] | M Move to specified line: 23, 29CO100 Copy 23 ~ 29 lines and paste them to 100 rows: SET NU Display line number: = Display the head line number:. = First is the current line line number Row address symbol. Current line $ Finally with a line% file per row (1, $) back - forward:. 20 # first from the current line 20 line number: g Global Search: g / pattern Search Row: g! / Patterhn Search not compliance with rows: W Save but do not quit.: W [newfile] Save the current modification to a new file.: Wq || zz Save Exit.: E Do not save the current modification, Back to the initial version file.: Q Exit does not save.: X Write the file and introduce the editor: 1, 10W >> [newfile] Use >> Redirect Add in the Add in the file: read [file] Read Existing file data in the system: r [file]: 0R [file] Put the file to be read to the current file: 12R [file] Put the file to be read to the current file 12 lines of VI can open multiple Document, switch between files, such as VI TEMP TEST, via: vi Temp,: vi test,: n command can call another file: g |: s Global Replace / g Replace in the current line : S / OLD / New / G Current Row Global Replace OLD Character is New: 1, $ S / OLD / New / G Global Replace: 1, 50S / OLD / New / G Replace 1 ~ 50 lines: GC Confirmation, Y Replace N-repetition search% s / editer / editor / g ==: g / editer / s // editor / gGREP / SED / AWK regular expression. Match single character * Match 0 or more instances of the individual characters in front: Bugs * == bug | bugs *. Match any number of any character ^ Used for the start of the regular expression $ / regards the following characters as a normal character: / * == * [ ] Matching any one of the included characters: p [aeiout] r == PAR | PER ....: g / ^ $ / d Delete All space line / u replacement characters for uppercase & Recover Advanced Vi Command: Set Option Settings Option: SET NOOTION Close Options Settings: SET All Display All Options: Set IC Specify Mode Search ignore the case: SET NOIC Do not ignore the .exrc file Control the EXRC file of the VI environment is located in the main directory (the directory where you are in the first login), you can Modify the .exrc file: SO SourceFile You can call the option to set up the option for the SourceFile: Set AutoIndent Auto Confincide Ctrl D Cancel Canced Level (Insert Mode) CRTL T Implement another indentation level (insert mode ) >> Live right shift (default 8 space - Increte the player into the text) << Live left shift 8 space 5 >> Move this paragraph in the top 5 lines: set shiftWidth = 4 This option can be changed Number of spaces for default: SET TABSTOP = 4 Sets the number of tab tab symbols: set list set tabs displayed as ^ i, the thread is displayed as $, usually on the screen, and blank display is blank .

转载请注明原文地址:https://www.9cbs.com/read-107965.html

New Post(0)