Windows operations 1. Introduction to Windows operation
Vim can open multiple windows in one interface for editing, which are called Vim windows. There are many ways to open a method, for example, you can use the command line mode input to :new
open a new Vim window, and enter the window to edit a new file (Normal mode Ctrl+w
can also be entered, but Ctrl+w
in Chrome will be closed tab page with Chrome shortcut keys conflict, So with this shortcut you can practice in IE or other browsers, in addition to the :new
command, the following list of methods can also be used in command mode or Normal mode to open a new window:
- Command-line mode enter
:sp 1.txt
open new Landscape window to edit 1.txt
- Command-line mode
:vsp 2.txt
to open a new vertical window to edit 1.txt
Ctrl-w s
split the current window into two horizontal windows in normal mode
Ctrl-w v
split the current window into two vertical windows in normal mode
- In normal mode
Ctrl-w q
, it is: Q ends the split window. If you have input in a new window, you need to use the mandatory character! namely: q!
Ctrl-w o
Open a window in normal mode and hide all previous windows
Ctrl-w j
move to the following window in normal mode
Ctrl-w k
move to the upper window in normal mode
Ctrl-w h
move to the left window in normal mode
Ctrl-w l
move to the right window in normal mode
Ctrl-w J
move the current window below in normal mode
Ctrl-w K
move the current window to the top in normal mode
Ctrl-w H
move the current window to the left in normal mode
Ctrl-w L
move the current window to the right in normal mode
Ctrl-w -
reduce the height of the window in normal mode
Ctrl-w +
increase the height of the window in normal mode
2. Windows Operation exercises
Open the practice file
$ vim 1.txt
- command-line mode input
:new
open a new vim window
- Command-line mode enter
:vsp 2.txt
open new Landscape window to edit 2.txt
- Command-line mode enter
:vsp 3.txt
open new Landscape window to edit 3.txt
- If you use a non-Chrome browser, you can use
Ctrl+w
the jump between windows
- Enter
:q!
exit multi-window editing in command-line mode of different windows
Vim window operation