Summary of common commands and skills of the vi text processor

Source: Internet
Author: User
Vi common commands and techniques summary vi is divided into three modes: General mode, edit mode, command line command mode General mode: Move the cursor, search, replace, delete characters, delete the entire row, copy and paste the entire row. In normal mode, press ioaR to enter the editing mode. you can enter any characters... summary of common commands and techniques used by the vi text processor vi is divided into three modes: General mode, edit mode, command line command mode, General mode: Move the cursor, search, replace, delete characters, delete the entire row, copy and paste the entire row. In normal mode, press ioaR to enter the editing mode. you can enter any character and press [esc] to exit the normal mode. Command line mode: Read, store files, and other additional functions. (:/?) # Vi test.txt General mode: hjkl move the cursor up and down to the right; ctrl + f flip down one page, ctrl + B flip up one page; 0 move to the beginning of the line character, $ move to the end of the row. G moves to the last row, 50 GB moves to the 50th rows of the file, gg equal to 1 GB;/word searches down the word string? Word search up word string: 100,200 s/word1/word2/g search for word1 between 100th and 200 to change word1 to word2: 1, $ s/word1/word2/gc searches for replacement from 1 to the last line. before replacement, the user is prompted to confirm conform p, P paste to the cursor down/up line u repeat the previous action ctrl + r redo the previous operation yy copy the row where the cursor is located nyy copy n lines command line mode: w write: w! Force write: q leaves vi: q! Do not save, force exit: wq save exit: wq! Force save and exit: set nu set row number: set nonu cancel row number: n1, n2 w [filename] store n1 to n2 row as file filename: r [filename] add the content of the read file to the cursor and then select the additional function block of mongovim (vcharacter selection, V line selection, [CTRL] + v block selection, y copy, d delete) press ctrl + v, move the arrow key, move down to the right, select area White, press y to copy, and p to the appropriate position. Multi-file edit vim file1 file2 (: n edit next File,: N edit previous file,: files list all files opened by current vim) multi-window function :: sp [filename] opens a new window. if filename is added, a new file is opened in the new window, otherwise, the two windows display the same file content synchronously Ctrl + wj cursor move to the lower window ctrl + wk cursor move to the upper window ctrl + wq end exit vim environment parameter settings: set nu set row number: set hlsearch: set nohlsearch: set auttoindent: set Auto Indent: set: noautoindent: set backup sets whether to automatically store backup file settings. when file1 is changed when any file is changed, file1 ~: Set rspace: set showmode: set backspace = (012): set all: syntax (on/off) alias setting alias lm = 'ls-l | more 'dos and unix line breaks (dos: ^ M $ LINUX: $) dos2unix [-kn] file [newfile] unix2dos [-kn] file [newfile]-k keep the original mtime format of the file-n keep the original file dos2unix-n old new

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.