Multi-window usage skills of Vim under Linux system


Internet   11-16 12:01:44 Author: Anonymous   I want to comment

This article mainly introduces the multi-window usage skills of Vim under Linux system. Vim is one of the two most powerful code editors in the world. Friends who need it can refer to the following

Use vsp command: For
example: there are files in a folder:

copy code
code show as below:
vector.cc, substr.cc

1. Use the vim command to open any file: vim vector.cc opens the first file. As shown below:
20151116115952639.jpg (594×397)

2. Press: "Esc" key + ":", and enter

copy code
code show as below:
:vsp substr.cc
  . (Here vsp is the same as vi/vim operation, and the path can be switched freely.) As shown in the following figure:
20151116120009886.jpg (569×433)

3. Press the "Enter" key. As shown below:
20151116120049113.jpg (802×400)
4. In order to allow the mouse to switch freely between several screens.
Press: "Esc" key + ":", enter:

copy code
code show as below:
set mouse=a
. Then, press Enter, so the mouse can move freely between multiple screens. As shown below:
20151116120107221.jpg (806×409)


General operation of vim multi-window:

1.
Open multiple windows The commands to open multiple windows are as follows:
Horizontal split window
: new + window name (the file name after saving)
: split + window name, which can also be abbreviated as: sp + window name
Vertical split window name
: vsplit + window The name can also be abbreviated as: vsp+window name
2. To close multiple windows,
you can use: q!, or you can use: close, the last window cannot be closed with close. Using close only temporarily closes the window, and its content is still in the cache. Only use q!, w! or x to really exit. : tabc
closes the current window : tabo
closes all windows Switch windows. 4. Window size adjustment Vertical adjustment : ctrl+w + vertical expansion (increase the number of lines) :ctrl+w - vertical reduction (the number of lines decreases) :res(ize) num For example: :res 5, the number of displayed lines is adjusted to 5 lines :res(ize)+num Increase the height of the current window by num lines :res(ize)-num Decrease the height of the current window by num lines Horizontal adjustment : vertical res(ize) num Specify the current window as num columns : vertical res(ize)+ num increases the current window by num columns : vertical res(ize)-num reduces the current window by num columns













5. Rename the window
: f file
6. vi open multiple files
vi abc
:n jump to the next file, you can also directly specify the file to be jumped, such as: nc, you can jump directly to the c file
: e# go back to the edit just now 7. File
browsing
: Ex Open the directory browser, you can browse all the files in the current directory, and you can choose
: Sex to split the current window horizontally, and open the directory browser in one window
: ls Display the current buffer situation
8. vi Switch with shell
: shell can switch to shell command line without closing vi
: exit from shell back to vi

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324601820&siteId=291194637