Linux study notes the VIM editor

Where necessary, only a list of some commonly used commands and usage

Fives. VIM program editor
Vi and vim

Vi open the document does not highlight annotation, there is vim and vim is an advanced version of vi

Vim default Open File command mode

i enter insert mode from point

I enter insert mode from the beginning of the line

insert mode enters a next character from the current cursor

A enter insert mode from the end of the line

o a blank line on the next line into the insert mode Bank

O blank line is generated from the line in insert mode, the Bank

u is in the command mode withdrawal step, (ctrl + r denotes forward)

: Colon enter command mode from mode (shift + :);

/ Feed command mode from search mode (shift + /)

Esc from any other mode to the command mode

Colon mode
save (w) exit (q) strong back (q!)

s / keywords / replacement word / replace the first row of the current key word replacement

s / keywords / replacement word / g for all keywords in the current line

3,13s / keywords / replacement word / g will replace the keyword line 3 to line 13 (the number represented to)

., 12s / keywords / Replace word / g replace all of the keywords the current line to 12 lines appear (Indicates current line)

., $ - 1s / keywords / Replace word / g replace all of the keywords of the current line to the penultimate line appears ($ represent the last line)

Keyword% s / keywords / replacement word / g alternative text appears (represented by 1%, i.e. $ from the first to the last row)

% S / g replace keyword // keyword text that appears empty (ie delete keywords appear in full text)

L1, L2s / ^ / # / g row lines L1 to L2 in the first row to add # (^ represents the beginning of a line)

L1, L2s / ^ # // g from line L1 to line L2, delete numbers beginning with # #

Number locate the beginning of the line number of the line

set number display line numbers

set nonuber withdrawal line number

files to view open files

next switched to the next file is opened

N switch to a file

n is switched to the next file

a first switch to the first file

last to switch to the last file

Find mode
key to highlight the full text keywords

n represents a key

N represents a keyword

Command Mode
Number + G positioned on the first line number

Positioning the last line G

gg is positioned to the first row

yy Copy current line

number + yy Copy current line plus the number of lines (lines starting from the current number later)

p paste it into the current line of the next line

dd deletes the current line (actually shear)

number + dd deleted from the beginning of the current line number (actually shear)

r + current character substitution character

x delete the character at the current cursor

six. The VIM function
block selection (Block Visual)
the Ctrl + V block selection start Visual

y copy the selected block

p paste the copied block

Multi-file editing
multi-window operation
into the colon mode, input sp

Ctrl + w then press the arrow jump to the next window

Ctrl + ww to switch to another window

May be added to the set command in ~ / .vimrc, the configuration vim (such as adding the line number)

DOS and Linux line breaks character

unix2dos -k -n file1 file2 convert file1 file2 to the file can be read dos

-k said they did not change the modification time

Guess you like

Origin blog.51cto.com/13293070/2429574