Linux VIM Basic command

Source: Internet
Author: User
Tags save file

Linux VIM command: 1.vim# enter vim on the command line, enter the VIM editor 2.i# Click the i key, the lower display--insert--#插入命令, in Vim may have any character 3. esc# exit I (insert) command for other commands to use 7.:! Command temporarily leaves VI to command column mode to perform command display results! For example:!ls# executes the shell command during the editing process ls8.:sh# enters the shell command line, after executing the command ctrl+d exit re-enter VIM edit continue editing under the shell command, execute ctral+l complete the screen 12.:set number or: Set nu# make the edited file display line number 13.:set Nonumber or: Set Nonu #与上一条命令相反, do not display line number 14.:help i# view Insert command Help 15.u #撤消上一步操作16./fedora# Find Fedora characters 17.:s /fedora/redhat# replaces the Fedora character with Redhat (replaces only the line where the cursor is located) 18.dw# Delete the word dd# delete the row 19.o# open a blank line 20.vim + filename# make the last line of the file edit 21.vim +n filename# Enter the nth line of the file for editing 22.:1,.s/redhat/fedora#. Indicates the current line, that is, the line of the cursor # will line 1th to the current line (.) The first occurrence of the Redhat character replaces the 1th line to the current line (.) instead of the fedora23.:1,.s/redhat/fedora/g#. All occurrences of the redhat character are replaced by the FEDORA,G global flag 24.:1, $s/redhat/fedora/g#$ represents the last line # to replace all occurrences of redhat characters in line 1th to the last line fedora25.:%s/redhat/                                                            fedora/g# the same command 26.:%s/\/fedora/g# the 1th line to the last line all occurrences of the Redhat word instead of the fedora# word, instead of the character 27.:f# display the contents of the file, status, etc. # with the Ctrl+g command VIM command Daquan Cursor Control command command cursor move h move left one character J to  Move down one line K up one row L                 Move right one character G to the last line of the file: 1 move to the first line of the file W moves to the beginning of the next word w                   Moves to the beginning of the next word, ignoring the punctuation e moves to the end of the next word, E moves to the end of the next word, and ignores punctuation B moves to the beginning of the previous word b                       Move to the beginning of the previous word, ignoring the punctuation mark L moves to the last line of the screen m moves to the middle line of the screen H moves to the first line of the screen ( Move to the beginning of a sentence move to the end of the sentence {move to the beginning of the paragraph} to the next paragraph opening                Head 0 (number), |                       Move to the first column of the current row ^ move to the first non-null character of the current line move to the last character of the current line +, Enter moves to the first character of the next line-                    Move to the first non-null character of the previous line add a text command in VI Insert action A after the cursor insert text A at the end of the current line insert text I                   Insert text before cursor I insert a text before the current line O insert a new row below the current line O insert a new row at the top of the current row s    Delete the character at the cursor and enter insert mode s to delete the line where the cursor is located, and enter insert mode: R file reads the file contents and inserts it into the current line: NR file        Read the file contents and plug in the nth line after ESC back to command mode delete text in VI command delete operation x Delete character at cursor DW               Delete to the beginning of the next word DG deletes the line of the cursor until the end of the file DD delete the entire row of DB delete the word before the cursor: N,MD                  Delete n lines to M row D, d$ from the cursor to the end of the line d$ delete from the cursor to the end of the line d,d^ remove from the cursor to the beginning d^ Remove from cursor to the beginning of the line modify VI text The number preceding each command indicates the number of times the command was repeated command substitution operation Rchar Replace the current character with Char R Tex  T escape replaces the current character with text until the ESC key is pressed Stext escape uses text in place of the current character s or Cctext escape                     Text instead of the entire line Cwtext escape change the current word to textctext escape to change the remainder of the current line to TEXTCG escape                         Modify to end of file in VI Find and Replace command find and replace operation/text look forward in the file Text?text                       Look backwards in the file Textn in the same direction repeatedly find N in the opposite direction repeat lookup: set IC Ignore case when finding: set Noic is case sensitive when looking for: ranges/pat1/pat2/g replace Oldtext:m,ns/oldtext/newtext with NewText on M line N, replace oldtext& with NewText repeat last: s command: G/TEXT1/S/TEXT2/TEXT3 find rows containing Text1, with Tex T3 replaces the command represented by Text2:g/text/command on all lines that contain text: V/text/command runs on all lines that do not contain text comm                      The command represented by and is copied in vi copy the text command copy operation YY put the contents of the current row into a temporary buffer nyy the contents of n rows into the temporary buffer p Place the text in the temporary buffer after P puts the text in the temporary buffer before the cursor in VI undo with duplicate command undo operation U Withdraw                  Cancel the last modification U undoes all modifications of the current line.                  Repeats the last modification, repeating the previous F, F, t, or T lookup commands in the opposite direction; Repeat the previous F, F, t, or T Lookup command "NP retrieval last nth Delete (the buffer has a certain number of deletions, typically 9) n repeats the preceding/or?" Find command n repeats the previous/or in the opposite direction? Command save text and Exit VI command save and/or exit operation: W Save the file but do not exit vi:w. File to save the modification in file but not exit Vi:w Q or ZZ or : x save file and exit vi:q!                   Do not save file, exit vi:e!               Discard all modifications, starting with the last save file and then editing the options in VI function: Set all print all options: Set nooption close option option: Set Nu        Print line number before each line: set Showmode whether the display is an input mode or a replacement mode: Set autoindent The indentation of the previous line, especially for multiline annotations: set Smartindent Provide automatic indentation for C programs: Set list Display tab (^I) and end-of-line symbols: Set ts=8 sets the tab for text input stops:set window=n sets the text window to display n rows The status option of VI ctrl+g displays the file name, the current line number, the total number of rows in the file, and the percentage of the file location: l Use the letter "L" to display many special characters, such as tabs and line breaks                         Position paragraph and placement mark options in text {insert {In first column to define a paragraph [[Return to the beginning of paragraph]] Move forward to the beginning of the next paragraph m (A-Z) marks the current position with a letter, such as using MZ to denote Mark Z ' (A-Z) to move the cursor to the specified marker, as in the ' Z table                      Show move to Z in VI join row option effect J connect next line to end of current line NJ connection after n row cursor placement with screen adjustment options               Action h move the cursor to the top row of the screen NH     Move the cursor to line N of the top row of the screen m moves the cursor to the middle of the screen L move the cursor to the bottom line of the screen NL moves the cursor to the bottom line of the screen Row n ^e (Ctrl+e) Scrolls the screen down a line ctrl+y scrolls the screen down one line ctrl+u scrolls the screen up half a page ctrl+d will roll the screen half page C Trl+b Scrolls the screen one page ctrl+f scrolls the screen down one page ctrl+l redraws the screen Z-return the current row to the top row of the screen Nz-ret                    The urn resets the nth row below the current row to the top row Z of the screen.                   Place the current row as the central NZ for the screen.                      Place the nth row on the current line at the center of the screen z to place the current row as the bottom row of the screen nz-the row n on the current line as the Shell Escape command option in the bottom row VI of the screen                         Role:!command executes command commands for the shell, such as:!ls:!! Execute the previous shell command: r!command read the command command input and insert, such as: R!ls will execute the LS first, and then read the content: W!command the current edited file as the command Standard input and execute command commands, such as: W!grep ALL:CD directory changes the current working directory to the directory represented by directory: SH launches a child shell, using the ^d ( CTRL+D) returns the macros and abbreviations in the shell program file that Vi:so file reads into and executes in command VI (avoid using control keys and symbols, do not use the character K, V, G, Q, V, *, = and function keys): Map key COMMAND_SEQ defines a key to run command_seq, such as: Map e ea, whenever you can move E to the end of a word to append text: Map shows all defined macros in the status line: Umap key deletes the macro for the key: AB string1 string2 defines an abbreviation that replaces the ST with string2 when inserting string1 Ring1.                     When you want to insert text, type string1 and then press ESC, the system inserts the STRING2:AB display all abbreviations: una string cancels the abbreviation of string indent text in VI option When ctrl+i or tab text is inserted, the width of the move is inserted, and the moving width is defined beforehand: Set AI turns on auto indent: Set Sw=n sets the move width to n The character n> causes n rows to move one width to the right, such as 3>> to move the next three rows to the right one moving width.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Linux VIM Basic command

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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: and provide relevant evidence. A staff member will contact you within 5 working days.