This article Original starting in public numbers: Programming for three minutes, the end the two-dimensional code.
Text editing, jump, delete, copy, replace these operations with vim really fast; but it seems like this is just simply can not convince me vim
more than the mouse place.
Take the time to get familiar of these, in addition to virtuoso accident, pulled up late at night in order to prevent the main fire, not a remote room, night taxi to the place, but found no server graphical interface, this time if the script written cooked, vim
operating 6
a few repair over, can minimize the loss, but also good night's sleep.
Advanced Features Getting Started
Article between the common operations that we have already mastered, then you engage in a little advanced operations, who basically saw every sigh, "you vim
how so 6 !.
- Edit multiple files, fast switching between files
- Edit multiple documents time-division-screen operation
- Batch Comment multiple lines of code, modify the configuration, delete area Copy
Edit multiple files
Edit two files 1.txt
,2.txt
vim 1.txt 2.txt
Check which files are open at the same time :ls
, which %a
represents the file being edited.
Switching between files :n
,:N
Switch directly to the file you want to edit :b 1.txt
Of course, why we jump around, because this can be done in combination copy and paste and other operations across multiple files.
Split Screen
Create a split screen
:sp 2.txt
Open a new level split screen (up and down) to edit window2.txt
:vsp 2.txt
Open a new split-screen vertical (horizontal) to edit window2.txt
Split screen split screen to jump and move
I opened the first three documents,1.txt
2.txt
3.txt
Now I were to jump to the file, delete the file contents.
Normal mode Ctrl+w j
Move to the next window
Normal mode Ctrl+w k
move to the top window
In normal mode Ctrl+w h
moves to the left window
Normal mode Ctrl+w l
shift to the right window
Now I opened the three vertical file, use the following command to move the window, first 文件3
moved from the far left to far right, and then move the next lowermost
Normal mode Ctrl+w J
will move below the current window
Normal mode Ctrl+w K
will move above the current window
In normal mode Ctrl+w H
the current window moves to the left
Normal mode Ctrl+w L
will move to the right of the current window
As long as located in the corresponding window :q
:wq
q!
to exit can; wqa
or qa!
to withdraw from
Visual mode
Visual mode is divided into three, also vim
of the essence. Each row, select the rectangular area, the character paragraph selection.
And similar to the mouse to select, enter visual mode plus symbol positioning can quickly jump to the range you want to select, then copied later selected, delete and other operations.
Select row
Row selection Shift+v(小写)
, to select an entire row, the cursor can be moved up and down more selected rows, press Shift+v
can deselect.
Below, into the row selection mode, input 4G
, jump to the fourth row, d
delete the selected area.
Selecting a rectangular area
A rectangular area selected Ctrl+v(小写)
by region selection, the cursor can move up and down more selected areas, press Ctrl+v
can deselect.
As follows: Select all of the row and first column in the region where, shift+i
in insert mode, insertion #
, double twice esc
, bulk annotation. Then repeat the selection operation, the input x
to delete the selected area.
Character selection (select the paragraph)
Character selection v(小写)
, move the cursor, the cursor through the place will be selected. Press again v
will deselect later.
As follows: v$
check 192.168.1.2
back in order not to select a cell line breaks, to paste the first line ip
and then select the unwanted ip deleted.
Visual mode and the best combination locator!
summary
Edit multiple files simultaneously: vim 1.txt 2.txt
to switch documents :n
, :N
,:b 1.txt
Split-screen :sp 2.txt
:vsp 2.txt
, jump Ctrl+w h|j|k|l
movement split screen bit
PutCtrl+w H|J|K|L
Visual mode Shift+v
, Ctrl+v
,v
vim
Command more, just to name the most useful enough to cope with all the scenes, and remember more faster!