Common UNIX Commands

  

vi Full Screen Editor vi (Visual) is a visually oriented full-screen editor, divided into three modes (mode): command mode: any input will be used as an edit command, not Appears on the screen, if there is an error, there is a sound of “岬”; any input causes immediate reflection. Insert mode: Any input data is placed in the edit register. Enter (I, a, A, etc.) in the command mode to enter the insert mode. Press ESC in the insert mode to jump back to the command mode. Escape mode: The instruction that is preceded by “:” or “/” appears on the bottom line of the screen, and any input is treated as a special instruction. Go to vi (enter the following command at the system prompt): vi Enter vi without reading any files vi filename Go to vi and read in the file with the specified name (both new and old). Vi +n filename Enter vi and start with the first few lines of the file. Vi +filename Enter vi and start with the last line of the file. Vi + /word filename Enter vi and start with the word word for the file. Vi filename(s) Enter vi and put each specified file on the list. The first file is read first. Vedit enters vi and displays "lds; INSERT MODE" on the status line when typing. Edit several files (using vi filename(s)) to enter vi) :args Displays the names of the files in the edit list: n Read the next file in the edit list: rew Read the first file in the edit list: e# Read the previous file in the edit list: e file Read another file into vi (this file can not be in the edit list), if the original file has not been archived after modification, you should first: w archive. :e! file Forces reading another file into vi, the original file is not archived. Store and exit vi :w filename Save the specified file, but do not exit vi (if the file name is not specified, it is the file name of the current work). :wq or :x or zz Save the file and exit vi. :q without making any changes and exit vi. :q! Discard any changes and quit vi. :!command Temporarily exit vi and execute the shell command, and then return to vi after execution. :sh Temporarily exit vi to the system, press Ctrl + d at the end to return to vi. Add data command i Start inserting characters at the mark position, and press ESC at the end. I Start adding words at the beginning of the line where the cursor is located, and press the ESC key at the end. a Start adding words after the cursor position, and press the ESC key at the end. A Start adding words at the end of the line where the cursor is located, and press the ESC key at the end. o Add a blank line under the cursor and start adding words. Press ESC at the end. O Add a blank line to the cursor and start adding words. Press ESC at the end. !command executes the shell command and adds the result to the next line of the line where the cursor is. Delete command nx Deletes the n characters starting from the cursor position (including the cursor position, pressing an x ​​to delete the character where the cursor is located) nX Deletes the n characters starting from the cursor position (excluding the cursor position). Ndw deletes the actual n character groups (words) at the cursor position. D0 Deletes all characters from the beginning of the line to the cursor position. d$ or D Deletes all characters starting from the cursor position to the end of the line. Ndd deletes the n lines (the entire line) at the beginning of the cursor position (dd indicates the line where the cursor is deleted). :start,endd Deletes the start to end line of the file. Mark movement 0 Move to the beginning of a line $ Move to the end of a line [ Move to the beginning of the file] Move to the end of the file nh Move n bits to the left nl or spacebar Move n bits to the right nk Move n lines up n+ Move up n Line, the cursor at the beginning of the line ni moves down n lines n- moves down n lines, the cursor at the beginning of the line H moves to the upper left corner of the screen M moves to the beginning of the middle line of the screen L moves to the screen The last line G moves to the last line of the file nG or :n moves to the nth line of the file nw shifts n words to the right, punctuation belongs to the word group nW right shift n words, mark The dot symbol does not belong to the block nb. The left shift is n blocks. The punctuation marks belong to the block nB. The left shift is n blocks. The punctuation does not belong to the block. Ctrl + u The volume on the screen is half menu Ctrl + d The screen is half a volume Menu Ctrl + b Roll a menu on the screen Ctrl + F Scroll down a menu Modify the command r Modify the character of the cursor file R Start from the cursor position, press ESC key at the end to change the n group of characters, press ESC at the end ncc from At the cursor position, start changing n lines. Press ESC at the end to reorder each line length i and press Enter to disconnect the line from the cursor and enter insert mode. J. Connect the next line of data to the line. Find the string text ?tex from the cursor position down t Look for the string text from the cursor position. n Continue to find the next string (used after entering the search instruction above). Find and replace the command: getxt1/s//text2/options Replace text1 of each line with text2 option=g Indicates that all text1 in the file is replaced. If no option is entered, only the first text1 in each line is replaced. option=go displays the replaced lines on the screen. option=gc is required before each string is replaced. Confirm Start, endgtext1/s//text2/options Same as above, only find and replace the first start~end line. Or: Start,ends/text1/text2/options Copy and move files :first,last co dest Copy the data from first to last line below the target line (dest) :Start,end m dest Move data from start to end Go to the target line (dest). :r filename Reads the contents of the specified file into the line under the cursor. nY Temporarily store n lines of data starting at the cursor position p Copy temporary data on the next line of the cursor P Copy the temporary data in the upper line of the cursor

Copyright © Windows knowledge All Rights Reserved