vim Advanced Features

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 vimmore 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, vimoperating 6a 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 vimhow 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 %arepresents 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.txtOpen 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 jMove to the next window

Normal mode Ctrl+w kmove to the top window

In normal mode Ctrl+w hmoves to the left window

Normal mode Ctrl+w lshift to the right window

Now I opened the three vertical file, use the following command to move the window, first 文件3moved from the far left to far right, and then move the next lowermost

Normal mode Ctrl+w Jwill move below the current window

Normal mode Ctrl+w Kwill move above the current window

In normal mode Ctrl+w Hthe current window moves to the left

Normal mode Ctrl+w Lwill move to the right of the current window

As long as located in the corresponding window :q :wq q!to exit can; wqaor qa!to withdraw from

Visual mode

Visual mode is divided into three, also vimof 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+vcan deselect.

Below, into the row selection mode, input 4G, jump to the fourth row, ddelete 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+vcan deselect.

As follows: Select all of the row and first column in the region where, shift+iin insert mode, insertion #, double twice esc, bulk annotation. Then repeat the selection operation, the input xto 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 vwill deselect later.

As follows: v$check 192.168.1.2back in order not to select a cell line breaks, to paste the first line ipand then select the unwanted ip deleted.

Visual mode and the best combination locator!

summary

Edit multiple files simultaneously: vim 1.txt 2.txtto switch documents :n, :N,:b 1.txt

Split-screen :sp 2.txt  :vsp 2.txt, jump Ctrl+w h|j|k|lmovement split screen bit

PutCtrl+w H|J|K|L

Visual mode Shift+v, Ctrl+v,v

vimCommand more, just to name the most useful enough to cope with all the scenes, and remember more faster!

Guess you like

Origin www.cnblogs.com/pzqu/p/11515625.html