Vim Editor Common commands

Source: Internet
Author: User
Tags ord save file

General Mode Common operation

"[Ctrl] + F" screen moves down one page (equivalent to page DOWN key)
"[Ctrl] + B" screen moves up one page (equivalent to page UP key)

"[0] or [Home]" cursor moves to the front of the current line
"[$] or [end]" cursor moves to the end of the current line

The "G" cursor moves to the last line of the file (at the first character)
"NG" N is a number (hereinafter), moving to the nth row in the current file
"GG" moves to the first line of the file, equivalent to "1G"
"N[enter]" cursor moves down n rows

"/word" finds a string in a file with Word (look down)
"? Word" finds a string in a file that contains word (look up)
"[n]" means a duplicate lookup action, which is to find the next
"[N]" reverse lookup next
": n1,n2s/word1/word2/g" N1, N2 as numbers, find N2 string between line N1 and Word1 line and replace it with WORD2
": 1,S/WORD1/WORD2/G】FromTheOneYes(TheNYesWithActing)ToMostAfterOneYesCheckFindWORD1NoteBook,AndWillIts change Wor d2 ":1 s/word1/word2/g "From the first row (nth line) to the last line to find word1 registration, and replace it with Word2": 1,s/word1/word2/gc "function as above, except that each time the user will be confirmed

"DD" deletes the entire line where the cursor is located
"NDD" Removes the downward n-line of the cursor

"YY" the line where the cursor is copied
"Nyy" Copy the down-n line where the cursor is located
"P,p" p to paste the copied data on the next line of the cursor; p to paste the data that has already been copied on one line of the cursor

"U" undoes the previous action
"[Ctrl] + R" undo multiple times

General mode switch to command line mode

": W" Save file
": w!" If the file is read-only, force the file to be saved
": Q" Leave VI
": q!" does not save forced departure VI
": Wq" left after saving
": wq!" forced to leave after saving
": Set nu" Displays line numbers
": Set Nonu" to suppress line numbers
": W newfile" Save As
": Set fileencoding" View the current file encoding format
": Set Fileencoding=utf-8" Sets the current file encoding format to Utf-8, or can be set to another encoding format

Multi-file editing
"Vim file1 file2" Open two files at a time
": N" edits the next file
": N" Edit Previous file
": Files" lists all files that are currently open with vim

Vim configuration file
The configuration file for Vim is/ETC/VIMRC, but it is generally not recommended to modify this file directly, but to create a new hidden file in the user root directory:
Vim ~/.VIMRC
Then edit this file, the usual configuration is as follows:
Bash
"The content behind the double quotation marks is a comment
Set Nu "Show line number
Set Hlsearch "lookup string anti-white display
Set backspace=2 "Can be deleted at any time with backspace bar
Set autoindent "Auto Indent
Set ruler "show status on the bottom row
Set Showmode "display mode in the lower left corner
Set Bg=dark "displays a different background color and can also be light
Syntax on "Grammar check, color display

Vim Editor Common commands

Related Article

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.