Vim tool use

1.VI and VIM three main modes: command mode switch to insert mode and extended mode:

Command mode cut into insert mode options:  

i Start insert mode at the cursor position 
A Append at the end of the line 
I Insert at the beginning of the line 
o Insert a new line (below this) 
O Insert a new line (above this)  

Command mode switch to extended mode:

: wq Save and exit 
: q! Exit             
: w 
Save How to save as: w File name 
: set number Display line number 
: set nonumber Cancel line number display
vim default mode: 
key movement and text operation commands 
The number in the command is used to repeat the command: for 
example: 
right direction // move one character to the right 
number n, right direction // move n characters to the right 
key movement: direction key hjkl 
press Word move: w, b 
move by sentence :), ( 
Move by segment: {,} 
Challenge to the xth line: xG 
Jump to the end: GG in 
lower case: Jump to 
GG in the same capital at the beginning : Jump To the last line
Command mode search and replace: 
like less, use /, n, N // n to search backward; N to search forward, 
like sed to find / replace 
    affect the current line by default 
    Use x, y to specify the range or% the entire file 
    : 1 , 5s / cat / dog / 
    :% s / cat / dog / gi
  change delete yank
Single line cc dd yy
Multi-line c3↑ d5↓ y2↑
word cw  dw is
       

Paste p (aste), cancel u (ndo), press w to jump words, and then use yw to copy; u cancels the most recent modification; U cancels all modifications to the line where the cursor is, Ctrl-r redoes the most recent "undone" modification ; V based on cursor highlight mode selection, then copy and paste, etc.

In fact, each line has a start and end identifier, the start identifier is ^, and the end identifier is $

Use cdy targeting, d ↑, y ↑ and other operations

Generate a file #man pwd | col -b> pwd.txt

2. Use multiple windows

You can view multiple documents in a single vim window: 
Ctrl-w, s split the screen horizontally 
Ctrl-w, v split the screen vertically 
Ctrl-w, the arrow keys move in the window quality inspection 
Ex-mode command is always effective for the current window 
: help windows shows more windows commands 
Use #vim -o (O) 1.txt 2.txt to open two files, use ctrl + w + ↑ ↓ ← → arrow to jump to the file

3. Multi-session editing conflict analysis and resolution

Two or more people edit the same file, the edited file will have the file name .swp, the second edited person will become .swo, and the edited person will become swn

4. VIM resource configuration file

Set the settings temporarily when vim is edited 
:: set 
: set all 
: set tabstop = 4  // Set tab jump to 4 spaces 
: set nonumber // Cancel line number display 
: set ignorecase // Ignore case, used for search 
: Set autoindent
: set textwidth = 65 (vim only)
: set wrapmargin = 15
permanent configuration
~ / .vimrcor ~ / .exrc
run: help option lists the complete configuration list

 

 

Guess you like

Origin www.cnblogs.com/hongjinping/p/12694547.html