There are four modes vim insert mode Normal mode command mode and the view mode
Normal mode is a normal-mode is generally text copy and paste , etc. from the operation terminals entered vim is the normal mode and enter the command mode is returned from the other before entering the normal mode by other modes ESC
Move the cursor H - Left j- at K - the L - Right
Copy yy to copy an entire row 3yy copy the current row three lines y $ Copy the current position to the end of the line
Paste p
Cut dd entire row 3dd current row three rows d $ (= D) the end of the current position to the line
Revoked u
Undo redo (undo canceled) Ctrl + r
Delete X (single character delete the entire line remove the available shear)
Alternatively r + character replacement (replacement single character)
Move the cursor location G - first line G - last line 3G - third row
Two Insert mode insert-mode is usually a file additions
From the normal mode into the insert mode command (but different insertion position cursor)
i is positioned at the cursor position
I cursor first trekking
a cursor position behind a
A cursor tail trekking
o cursor line above another line
O line below cursor new line
Three command mode is mainly for file save and exit from the normal mode input ( : ) to enter the command mode
Save w Example w file document file stored value
Exit q Example wq to save and exit q! Exit without saving
Find / Example / x x N- find the next one a n-
Alternatively s / old / new
Global Alternatively % s / old / new / g
Specified row replacement 7,9s / old / new / g replace lines 7-9
! + Command can execute bash commands when using vim
set nu- display line numbers set nonu- cancel the display line number set nohlsearch- off highlighting (bolus)
/ etc / vimrc is the vim configuration file can change its configuration file settings have been changed
vim file1 file2 can simultaneously open two files using the next and prev switching
View mode is divided into four character visual ( by v enter ) the row visible ( V ) and blocks visible ( Ctrl-v )
For visual block has a common operating multiple rows comment
Step: To select a first text I 3 2 and then press enter twice ESC @ 4 and knock