Summarizes the Linux vim editor

vi( Visual Interface )

vim (VI iMproveed): plain text (ASCII) full-screen editor, the editor is schematically.

vim of three modes:

1) Edit mode (command mode)

2) Input mode

3) line mode

Switching between the three modes:

1) Edit mode -> Input Mode:

i: current character in front of the cursor, into the input pattern;
A: after the current character of the cursor, into the input pattern;
O: below the current cursor line, the new line, and into the input mode;
    
the I : in the start of the current cursor line, into an input mode;
a: in the end of the current cursor line, into an input mode;
O: the line above the current cursor, the new line, and into the input mode.

2) Input mode -> Edit mode:

    ESC key once.

3) Edit mode -> line mode:

    :

4) line mode -> Edit mode:

    ESC key ESC key once or twice continuously.

                                                                                                                                                                                       Caption (Source network)

 

First, open the file
# vim / path / to / somefile
    vim + #: Open the file, and positioned on the first # line;
    vim +: Open File, navigate to the last row;
    vim + / the PATTERN: Open File, navigate to the first time pATTERN is matched to the line of the first line;
                        Description : # positive integer to decimal    pATTERN representatives of pattern matching;
    the default to open the file in edit mode.

Second, close the file
  1), close the file line mode

and: q
: wq save and exit
: q exit without saving!
: w Save
: w forcibly saved!
: wq ->: X -> equivalent

 2) to exit edit mode
     ZZ: Save and Exit

 

Third, moving the cursor (editing mode)

 1), character by character movement

 h: Left
 l: Right
 j: the
 upper: K
 #h: moving characters #

 2), the word mobile units

    w: Move to the first word of the next word
    e: Skip the current or next word suffix
    b: Skip the current or previous word word first   
    #w:

 3), the row jump

    0: absolute first line
    ^: The first line of the first non-blank character
    $: the absolute end of the line

 4), between the lines jump

    #G: Go to page # line;
    G: last line
    GG: first line
    
    line mode, directly to the line number: #

 

Fourth, scroll

Ctrl + f: turn down a screen (Forward)
ctrl + B: turn a screen (Back) upwardly

Ctrl + d: half a screen scroll down (Down)
ctrl + U: upturned half screen (up)

 

V. delete a single character

x: delete a single character at the cursor
#x: Delete at the cursor backward and character of #

 

Sixth, the delete command: d --delete

d command with (all) command to jump combination (# foremost, d, followed by a jump final)
#dw, #DE, #DB, # d $

dd: delete the current cursor line
#dd: delete including the current cursor line, including the # line

line mode: (d at the end) (as a separate address parameters, delete the row)
StartADD, EndADD d                   (StartADD, StartAddress - the StartLine)
    : Indicates the current line.
    $: the last line
    + # : a first down line #             
    - #: # line first upwardly

Seven, the Paste command p --paste (last delete the contents stored in memory can be used for paste)

p: If the copy or to delete whole line, below the line is attached to the cursor,
   if the content copy or delete a non-integer line, the paste of the following character cursor;
P: if the copy or to delete the entire line , stuck to the top of the cursor line,
   if the content of non-integer copy or delete rows, attached to the front of the character cursor;

Eight, the copy command y (yank)
    usage with the d command
    
IX Review: delete the contents, then converted to input mode
    c: Use the same d command (Change)
    C: directly cursor to the line and delete, and then converted to input mode

ten, replace: r --replace

r: replace one character
R: successive replacement single character



XI undone editing operation u (undo)

u: once before the undone editing operation
    continuously u command to undo previous edits n operation (stored in memory 50)
#U: # edits directly revokes the last operation

Undo Undo the last operation: Ctrl + r


Editing Operation Twelve, before repeating

. (Dot)

 

XIII visualization mode

 v Character selection, will move the cursor through the local anti-white selection (- VISUAL -)
V Row selection, the cursor will highlight the selected row through the (- VISUAL LINE -)
[Ctrl]+v Block selection, you can select data using rectangular way (- VISUAL BLOCK -)
Y The highlight of the local copy up
d The highlight of the place deleted
The above three modes can be selected for the text in various normal operating modes, the batch can be inserted through selecting specified text, delete, replace operation (e.g., multi-line script commented out)


Fourth, look for

/ PATTERN matching down
? Matching up the PATTERN
    n according to the next matches the direction
    N in accordance with one of the mating direction

Fifth, find and replace

S using the command line mode (with the same command sed)
ADDR1, the PATTERN ADDR2s @ @ @ String GI (G - Global, I - the ignore Case)
. 1, represents a full $
% represents full

 

Guess you like

Origin www.cnblogs.com/ant-colonies/p/6262380.html