您的位置:首页 > 运维架构 > Linux

【原创】Linux vi/vim 分屏

2017-03-20 14:45 447 查看
以竖屏方式打开新文件:(只输入vs,会默认再次垂直打开当前文件)
:vs new.txt
以横屏方式打开新文件:(只输入sp,会默认再次水平打开当前文件)
:sp new.txt

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

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

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

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

参见vi文档:

:
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 has
been
loaded |+cmd|.
Also see |++opt|.
Make new window N high (default is to use half the
existing
height).  Reduces the current window height
to create room
(and others, if the 'equalalways' option is set).

:
vs[plit] [++opt] [+cmd] [file] *:vs* *:vsplit*
Like |:split|, but split vertically.  The
windows 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 or
new
  window.
Note: In other places CTRL-Q does the same as CTRL-V, but
here
it doesn't!

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

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

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

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

:res[ize]

CTRL-W CTRL-_ *CTRL-W_CTRL-_* *CTRL-W__*
CTRL-W _ Set current window height to N (default: highest
possible).

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 (default
1).

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

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

The option 'winheight' ('wh') is used to set the minimal
window height of the
current window.  This option is used each
time another window becomes the
current window.  If the option is '0', it is
disabled.  Set 'winheight' to a
very large value, e.g., '9999', to make the current window
always fill all
available space.  Set it to a reasonable
value, e.g., '10', to make editing in
the current window comfortable.

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

When the option 'equalalways' ('ea') is set, all the windows
are 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 current
window and
leave the other windows the same.  When
closing 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 to
keep this width.
Likewise, "hor" causes only the widths of windows to be
equalized.

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

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

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

==============================================================================
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: