【原创】Linux vi/vim 分屏

来源:互联网 发布:hl线切割编程加工视频 编辑:程序博客网 时间:2024/05/25 18:09
以竖屏方式打开新文件:(只输入vs,会默认再次垂直打开当前文件)
:vs new.txt
以横屏方式打开新文件:(只输入sp,会默认再次水平打开当前文件)
:sp new.txt

【Ctrl】 + 【w】 + 【-】减小高度
【Ctrl】 + 【w】 +【+】增加高度

【Ctrl】 + 【w】 +【<】向左/右移动(在左右竖屏操作,效果会相反)
【Ctrl】 + 【w】 +【>】向右/左移动

【Ctrl】 + 【w】 + 【_】全屏显示(横屏)
【Ctrl】 + 【w】 + 【|】全屏显示(竖屏)

【Ctrl】 + 【w】 +【=】恢复调整中分宽度或高度(全屏效果也会恢复至中分)


参见vi文档:
:[N]sp[lit] [++opt] [+cmd] {file} *:split_f*
Create a new window and start editing file {file} in it. This
behaves like a ":split" first, and then an ":e" command.
If [+cmd] is given, execute the command when the file hasbeen
loaded |+cmd|.
Also see |++opt|.
Make new window N high (default is to use half theexisting
height).  Reduces the current window heightto create room
(and others, if the 'equalalways' option is set).

:[N]vs[plit] [++opt] [+cmd] [file] *:vs* *:vsplit*
Like |:split|, but split vertically.  Thewindows will be
spread out horizontally if
1. a width was not specified,
2. 'equalalways' is set,
3. 'eadirection' isn't "ver", and
4. one of the other windows is wider than the current ornew
  window.
Note: In other places CTRL-Q does the same as CTRL-V, buthere
it doesn't!

==============================================================================
6. Window resizing *window-resize*

*CTRL-W_=*
CTRL-W = Make all windows (almost) equally high and wide, butuse
'winheight' and 'winwidth' for the current window.
Windows with 'winfixheight' set keep their height andwindows
with 'winfixwidth' set keep their width.

:res[ize] -N *:res* *:resize* *CTRL-W_-*
CTRL-W - Decrease current window height by N (default1).
If used after |:vertical|: decrease width by N.

:res[ize] +N *CTRL-W_+*
CTRL-W + Increase current window height by N (default1).
If used after |:vertical|: increase width by N.

:res[ize] [N]
CTRL-W CTRL-_ *CTRL-W_CTRL-_* *CTRL-W__*
CTRL-W _ Set current window height to N (default: highestpossible).

z{nr} Set current window height to {nr}.

*CTRL-W_<*
CTRL-W <<span class="Apple-tab-span"style="white-space:pre"> Decrease current window width by N(default 1).

*CTRL-W_>*
CTRL-W > Increase current window width by N (default1).

:vertical res[ize] [N] *:vertical-resize* *CTRL-W_bar*
CTRL-W | Set current window width to N (default: widestpossible).

You can also resize a window by dragging a status line up ordown with the
mouse.  Or by dragging a vertical separatorline left or right.  This only
works if the version of Vim that is being used supports themouse and the
'mouse' option has been set to enable it.

The option 'winheight' ('wh') is used to set the minimalwindow height of the
current window.  This option is used eachtime another window becomes the
current window.  If the option is '0', it isdisabled.  Set 'winheight' to a
very large value, e.g., '9999', to make the current windowalways fill all
available space.  Set it to a reasonablevalue, e.g., '10', to make editing in
the current window comfortable.

The equivalent 'winwidth' ('wiw') option is used to set theminimal width of
the current window.

When the option 'equalalways' ('ea') is set, all the windowsare automatically
made the same size after splitting or closing a window. If you don't set this
option, splitting a window will reduce the size of the currentwindow and
leave the other windows the same.  Whenclosing a window, the extra lines are
given to the window above it.

The 'eadirection' option limits the direction in which the'equalalways'
option is applied.  The default "both"resizes in both directions.  When the
value is "ver" only the heights of windows are equalized. Use this when you
have manually resized a vertically split window and want tokeep this width.
Likewise, "hor" causes only the widths of windows to beequalized.

The option 'cmdheight' ('ch') is used to set the height of thecommand-line.
If you are annoyed by the |hit-enter| prompt for longmessages, set this
option to 2 or 3.

If there is only one window, resizing that window will alsochange the command
line height.  If there are several windows,resizing the current window will
also change the height of the window below it (and sometimesthe window above
it).

The minimal height and width of a window is set with'winminheight' and
'winminwidth'.  These are hard values, awindow will never become smaller.

==============================================================================

0 0