Linux Foundation--3vim Edit

Source: Internet
Author: User

VIM CV
Vim is a powerful full-screen text editor, the most commonly used text editor on Linux/unix, and its role is to create,

display text files.
#vi/~/.BASHRC
environment variable configuration file, need to log back in to take effect use the following two commands to avoid re-login
#source/~/.BASHRC #永久生效
#. . BASHRC
Alias vi= ' Vim ' reboot failed
Vim working mode

Command mode
Input mode
Last-line mode
Command----"Input A: Append i: Insert o: Open
Command----"last line: W (small) Save: Q (Small) do not save exit: Wq (Small) Save exit! Forced

: Q (SMALL)! (any user can use,): Wq (small)! (Only the root user is available): W file name saved as
Enter----last line
Insert command:
A specifier insert in the word cursor
A at the end of the line where the cursor is inserted
I match either insert in the word cursor
I Insert at the beginning of the line where the cursor
o Insert a new line under the cursor
O insert a new line on the cursor
2 Command mode operation
1) Cursor Movement
H move J down move K up move L move right
2) Move the cursor to the head or end of the file
GG Move to file header
Shift+g g move to end of file
^ Move to the beginning of the line
$ move to end of line
N: Move to the first few lines
3) Delete Letters
X Delete the character at cursor location
NX removes the n characters after the cursor is located
DD Delete Row of cursor, NDD delete n rows
: n1,n2d deletes a specified range of rows
4) Delete entire row clipping

DD Delete a single line
NDD Delete multiple lines
P paste
P (Large) paste in front of cursor
DG is removed from the line of the cursor to the end of the file
5) Copy
YY copy when moving forward
Nyy Copy the current row following n rows
DD Cut when moving forward
NDD cuts the current row following n rows
P, p pasted under the current cursor row or line
NP, NP paste multiple lines under the current cursor line or line
6) Revocation
U undo
Ctrl+r Anti-Revocation
7) Display line number
: Set Nu
: Set Nonu
8) Color Switch
: Syntax off
: Syntax on
9) Replacement and cancellation of commands
R replaces the character where the cursor is located (replaces only one character at the cursor)
R replaces the character at the beginning of the cursor and presses ESC to end
U Cancel the previous action
Find
"/" Find
N is the next, N previous
VI Configuration file
Search and search Replacement commands
String search ignores case when searching for a specified string: setic
n searches for the next occurrence of the specified string
:%s/old/new/g full text Replace specified string
: N1,n2s/old/new/g replaces specified string within a certain range
Save and Exit commands
: W Save changes
: New_filename Save as specified file
: Wq Save changes and exit
ZZ (shift+zz) shortcut keys, save changes and exit
: q! Do not save changes to exit
: wq! Save changes and exit (file owner and root can be used)
1. Import command Execution result: r! command
Note:: R path Import path contents
:!whichl view LS path in edit state
2. Define shortcut keys: MAP shortcut Trigger command
Example:: Map ^pi#<esc> Note: Add # at the beginning of the line where the cursor is located and return
: Map ^b Ox Note: Delete the line at the beginning of your cursor
Note: ^p is a key combination of ctrl+v+p
3, Continuous line Note: n1,n2s/^/#/g Note: At the beginning of the N1,N2 add #
: n1,n2s/^/#//g Note: Delete # at the beginning of the N1,N2
: n1,n2s/^/\/\/g Note: At the beginning of n1,n2, add//
4. Replacement: AB [email protected]
Note: input mymail automatically replaced by [email protected]

Section: VI Open two files at the same time VI file 1-o file 2 split screen display SP, toggle ctrl+w+ up/down arrow
In ~/. VIMRC file added set Nu save



This article from "Wu Dick" blog, declined reprint!

Linux Foundation--3vim Edit

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.