Functions of the vim editor

Source: Internet
Author: User
The role of the vim editor is vim: write a script to change the configuration file. the newly created configuration file is mongoroot@teacherlianxi?vimyaan.txt *********** the File next to the vim editor. if it exists, it is to open it... the role of the vim editor: write a script to change the configuration file to create a text file =================[ root @ teacher lianxi] # vim yaan.txt ***** * ***** the file after the vim editor, if it exists, it is enabled. if it does not exist, it is introduced to the new mode: the default mode of vim startup in command mode. in other modes, press ESC to return to the INSERT mode) insert text to the text and press ESC to return to the command mode. There are three common methods to enter the insert mode. 1. the I (insert) cursor enters the insert mode at the current position. 2: a (append) move the cursor backward to insert mode. 3: o starts a new row under the row where the cursor is located and enters insert mode. The mode (VISUAL) move command expands the highlighted text area, and the lower case v enters the VISUAL mode. the upper case V enters the VISUAL line mode, and the ctrl + v enters the VISUAL block mode Replace mode) in command mode, press "R" to enter the replacement mode. in command line mode, enter the text that will be interpreted and executed. in command mode, enter: to exit the vim editor in the last line mode: q. If no changes are made to the file, exit: q! Discard save and exit: wq save the current file and exit: wq! Force save current file and exit: x Save current file and exit: x! Force save current file and exit ZZ save current file and exit (in command mode) cursor (glow mark) move pages in the direction: Page Down or Ctrl + F flip Down the entire Page content Page Up or Ctrl + B flip Up the entire Page content line to quickly jump to the Home key or "^" Escape character, number "0 "Jump to the beginning of the line End key or" $ "to jump to the End of the line quickly jump to 1G or gg to jump to the first line of the file G to jump to the End line of the file (go) # G jump to line # in the file. line 10: delete, copy, and paste. operation type: delete X or Del. delete a single character dd at the cursor. delete the row where the current cursor is located. # dd (# indicates number) delete the # row content starting from the cursor d ^ delete all the characters before the current cursor to the beginning of the line d $ delete all the characters from the current cursor to the behavior copy yy copy the entire row content to clipboard # yy (# represents a number) copy the line content starting from the cursor paste p paste the content in the buffer to the cursor position after P (uppercase) paste to the cursor position before the file content search/word from top down Search for the string "word" in the file "? Word searches for the string "word" n from the bottom up in the file to locate the next matched string (next) N locate the replacement operation (last line mode) of the content of the last matched string file: s/old/new replace the first string "old" found in the current row with the "new" string ": s/old/new/g replace all the strings "old" found in the current row with "new": #, # s/old/new/g in the row number "#, # Replace all strings "old" with "new" in the "range ": % s/old/new/g replace all strings "old" with "new" within the entire file range: s/old/new/c add the c command at the end of the replacement command, the c prompt replace with old (y/n/a/q/l/^ E/^ Y) will be added at the end of each replacement action prompt user confirmation )? Y is yes replace n is no do not replace a is all replace q is quit exit do not replace l is line replace the whole line ************* * ***** escape characters are required: % s/huhu /\! \! /G replace the entire file with huhu !! Read or open a new file: r/etc/passwd read other file content in the current file (read): e/etc/passwd open a new file for editing (edit, note the space between e and the file) line number display: set nu shows the line number in the editor: set nonu cancels the line number in the editor to display duplicate commands in command mode Press. the key class executes a duplicate operation. if you cancel the last operation, the u cancels the last operation. if you cancel multiple operations, press u multiple times to cancel all edits made to the current row and save them as: e! Undo all operations on the file and start again: w modify save to another folder: w + file name example: w/lianxi/pwd-2.txt (save as) multiple file operations: n. edit the next file: N. edit the previous File: files: list the files opened in vim, it does not loop, that is, when the first operation is performed on a file, it does not jump to the last file.

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.