Vim Compiler Summary

Source: Internet
Author: User
Tags exit in

  "Vim Compiler"

The VIM compiler is the text compiler that comes with the Linux system, and the personal view is very useful. The ability to skillfully use vim can greatly improve the efficiency of their own, can be more convenient.

Vim's working mode is divided into normal mode, insert mode and command mode. Just use VIM to open the file is normal mode, the normal mode can achieve the cursor movement and some shortcuts to the application, and then through the case into the insertion mode to achieve some basic text editing. Enter ":" Into the command mode in normal mode to implement some specified actions by entering a specific instruction.

Normal mode

Cursor Movement instruction: "h" cursor moves to the left one bit, "L" cursor to move to the right; "J" Light moves downward one bit; "k" Cursor moves up one bit; "GG" moves the cursor to the top of the file; "G" moves the cursor to the end of the file; "NG" moves to line N of the file The cursor moves to the first character and trailing character of the current line, the "FX, FX" cursor moves to the next, previous character in the current line, the "W/NW" cursor moves to the right by A/n word, and the "B/NB" cursor moves one/n words to the left.

Text Edit command: "x" deletes the single character where the cursor is located; "Dd/ndd" deletes the current row/n line; "d$" deletes the contents of the line at the end of the row; "J" Removes the line break from the next line to merge it with the Bank; "U" fallback undo the previous action like undo; "Rx" Replaces the current character of the cursor with X;PS:X as any character. "Yy/nyy" copies a row/n line; "p/p" pastes the contents of YY into the current line after/before;

  Insert mode

  Insert mode is normal text editing, except that the way you insert it is different. In normal mode, enter the following command to achieve the function: "a/i" into the insertion mode, and after the cursor position in/before the continuation of input; "A" enters the insertion mode while the cursor is in the paragraph after/before the input continues; "O/O" enters insert mode and creates a new blank line behind/before the current line ;

Press the ESC exit key to return to normal mode.

  Command mode

Enter ":" Into command mode in normal mode. Commands that can perform some text operations.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Split Line ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~

Vim's cursor operation:

Vim Editor is unable to move the cursor through the mouse, you can use the left and RIGHT arrow keys to achieve the operation of the cursor movement, you can also use a larger method to quickly achieve their desired cursor action.

"H": Left "J": Down (with carriage return as line break) "K": Up "L": Right

"GG": Move the cursor to the first line of the entire file "G": Move the cursor to the end of the entire file

"NG": Moving Light to Nth row (n is number)

"^": Move the Light to the first character of the current line "$" to move the cursor to the trailing character of the current line

"FX": the cursor moves to the next ' X ' character on the current line "FX": The light changes to the previous ' X ' character on the current line ps:x represents the character

"W": Move right one word "NW": move n words to the right ps:n to numbers

"B": Move left one word "NB": move n words to the left ps:n to numbers

Vim also has some shortcuts for editing text directly, so you can edit text more efficiently and quickly.

Enter edit mode by moving the cursor to change the basic operations such as adding or subtracting. In normal mode, the shortcut keys can be used to implement some simple modification tasks:

"x": Delete the character of the current position of the light change

"DD": Delete the current line PS: Hold down the D Word can be continuously deleted

"NDD": Delete n rows (down) ps:n as numbers

"d$": Delete the cursor to the end of the current line of content.

"J": Capitalize, remove line breaks, and combine two lines into one line.

"U": fallback to the previous action.

"RX": replaces the current character with an X ps:x for any keyboard single input

"yy": copy when moving forward

"P": pasted after the current line "P": pasted before the current line

Vim Compiler Find Replacement:

"/character": To find the same character or string within a file by '/' plus the character you want to find, jump to the next matched string and jump to the last matched string by ' n/n '.

": s/root/admin/": Replace the first ' root ' in the current line of the cursor with ' admin '

": s/root/admin/g": Replace All ' root ' of the cursor's current line with ' admin '

": 1,10 s/root/admin/g": Replace All ' root ' in rows 1 through 10 with ' admin '

":% s/root/admin/g": replace the entire document with ' admin ' for all ' root '

Finally, save and exit after text editing is complete

": q! ": Do not save exit

": Wq" ": X": Save and exit

": W": Save

": W 1.txt": Save current text as 1.txt

In addition, you can save and exit in normal mode if you want to lose like "ZZ".

There are a few other gadgets:

": Set Number" ": Set nu" function shows line number ": Set Nonu" suppress line numbers

": Set ignorecase": Ignore case, vim default is case-sensitive

Multiple windows:

": Split" opens the new window horizontally ": Vsplit" opens a new window vertically ": Close" closes the current Window ": Split 1.txt" opens a new file in a new window

When editing multiple documents at the same time, you can use this command to split the window, you can also achieve editing the same document different lines, the window switch operation can be achieved by shortcut keys. Ctrl+w+h jumps to the left one window, ctrl+w+l jumps to the right one window, ctrl+w+j jumps to the above one window, ctrl+w+k jumps to the following window

VIM executes the shell command:

【:! {command} "does not want to exit in vim edit but can be used when the shell command is executed, press ENTER to return to the Vim editing interface from the shell command result.

Vim is automatically padded:

If you want to enter the content in the current text before the line has already appeared, then you can write the first few characters followed by CTRL + N to automatically fill.

Permanent Display line number:

Input command: Vim ~/.VIMRC Open is an empty file, we add set Nu, save exit, again into the Vim editor, will automatically show the travel number.

Welcome to correct.

  

Vim Compiler Summary

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.