Vim editor frequently used functions to organize notes

Source: Internet
Author: User


Vim Editor
Vi:visual Inertface Visual Interface
VIM:VI Improved Extended version
Syntax coloring

Modal editor :
Edit mode (Command mode): Default mode
Input mode:
Last-line mode:
Wait for input command
10d Delete line Tenth
10,20d
Set NU Display line number
! Ls/etc do not exit the file input System shell command

Mode conversion
Edit-Input

Lowercase
I: Enter before the current cursor position
A: Enter after the current cursor position
O: Create a new line of input at the current cursor line
Capital
I beginning
End of a line
o Create a new row on the previous line


Input--Edit ESC

Edit-to-last line: You must enter from edit mode only: Colon

Last line--EDIT: ESC ESC

Feature Description:

First, open the file
Vim +12 cursor to 12 lines
VIM + open cursor to end
Vim +/patern Open file to position to first match

Second, close the file
Last-line mode close file: Wq ==:x
Edit mode Close file: Uppercase ZZ Save exit is Shift+zz


third, move the cursor (edit mode )
1. Move by character (hand position)
H
L
J Down
K On

8l Move left 8 characters
2. Move words by word
W moves to the beginning of the next word
E moves to the ending of the current or next word
b moves to the ending of the current or previous word
3w Jump backwards 3 words
3. In-line jump
0 (0) Absolute beginning
^ First non-whitespace character at the beginning of a line
$ Absolute Line End
4. Jump between rows
#G Jump To Line #
G jump to the last line
In the last line mode: directly to the line number enter

Four, turn the screen
CRTL+F: Flip one screen down
Crtl+b: Turn up one screen
Crtl+d: Flip Down half screen
Crtl+u: Flip up half screen
V. Delete a single character
#x delete the first # character x after the cursor is deleted delete a single

Vi. Delete command: D
d command and jump command combination using 3DW
#dw, #de #db
DD: Delete the current cursor line 3DD
#dd Delete the # line that includes the line where the current cursor is located
In the last line mode:
Staradd,endadd. , +5 means delete the current line to the following five lines
Supports relative notation:
. When moving forward
$ last line $-3
+# Down # line
Seven, paste command: P

Deleted items are not immediately deleted, and deleted content is saved in the buffer
The last deleted content can be pasted into the specified area can be pasted n times
Small P: If deleted or copied as an entire line, paste to the bottom of the row, not the entire row, then paste to the bottom of the row
Big P: On the contrary

Eight, copy command y
Usage with D

Nine, first delete the content, and then into the input mode
Modify
C: Use with D

Ten, replace a single character
R
R Replacement Mode

Xi. undo Edit Undo
U: Undo previous Operation Continuous use
Can only be saved in cache 50 times
3u to the third countdown
Regret to undo the operation, there is Crtl+r revocation undo, restore the last undo operation
Similar to the Crtl+z crtl+y under Window
12. Repeat the previous edit operation
Point command.
13. Visual operation
V: Select by character
V: Rectangle selection (entire row selected)

14. Find
/pattern looking backwards
? PATTERN Forward Lookup
N Next
N Previous

XV, find and replace
Usage same set
Use the S command in the last-line mode
Startadd,endadd @ pattern @string @gi
:., $-1 S/hello/hello @g
1,$ = =% Full text

16. Open multiple Files with vim
Copy and paste between multiple files
Vim file1 file2 File3
: Next switches to the previous file
:p Rev Switch to the previous file
: Last switch to final
: first to switch to file one
: QA All exit Q can only exit the current

17, split screen display a file (Word inside the window split)

Crtl+w,s: Horizontal splitter window
Crtl+w,v: Vertical splitter window
Switch between windows
Crtl+w,aprow (direction key) or two times Crtl+w can also switch down one
: QA Closes all windows

18, sub-Windows multiple files
Vim-o file1 file2 Horizontal Division
Vim-o file1 file2 Vertical Split

Switching is also crtl+w

19. Save some of the contents of the current file as a different file
Use the W command in the last row mode
: W
: ADDR1,ADDR2 W/path/to/somewhere


20. Populate the contents of another file in the current file
: R/root/inittal
Add the contents of another file directly at the back


21. Interacting with the shell
:!commen
Then return to the VI editing interface


22. Advanced Topics
1. Display or cancel line numbers
: Set Nu
: Set Nonu

2. Show ignore or differentiate character case: set ignorecase
: Set IC
: Set Noic

3. Set auto indent: Set autoindent
It's important to write script programming.
: Set AI
: Set Noai
4. Check the found text highlighting or cancel out
: Set Hlsearch
: Set Nohlsearch

5. Syntax highlighting
: Syntax on
: Syntax off

23. Configuration Files
/etc/vimrc
Single User home directory to create your own new. VIMRC
~/.vimrc

The VIM process often gets an error when it is forced out of the network
vim-r Inittab
FILE.SWP file To manually remove the backup file rm-f. inittab.swp

If This is the case, use ": Recover" or "vim-r inittab"
To recover the changes (see ": Help Recovery").
If you do this already, delete the swap file ". Inittab.swp"

Vim editor frequently used functions to organize notes

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.