博客主机
A-A+

vim窗口分割命令

2012年04月19日 Linux 暂无评论

在使用VIM时通常会有同事查看多个文件的情况,对此,vim提供了窗口分割的功能,以下是vim窗口分割的常用命令介绍:
^W指按ctrl-W

0、变换水平窗口分割和垂直窗口分割:
:切换两个垂直窗口到水平窗口
^Wt^WK
:切换两个水平窗口到垂直窗口
^Wt^H
where ^W means "hit Ctrl-W". Explanations:
^Wt    makes the first (topleft) window current
^WK   moves the current window to full-width at the very top
^WH   moves the current window to full-height at far left
Note that the t is lowercase, and the K and H are uppercase.
Also, with only two windows, it seems like you can drop the ^Wt part because if you're already in one of only two windows, what's the point of making it current?

1、水平窗口分割:
:split(开启另一个窗口察看同一文件)
:split 文件名(开启另一个窗口察看指定文件)
:30split 打开一个高度为30的窗口

2、垂直窗口分割:
:vsplit(开启另一个窗口察看同一文件)
:vsplit 文件名(开启另一个窗口察看指定文件)
:30split 打开一个宽度为30的窗口

3、同时打开文件,并在一个标签中显示在多个窗口中:
vim -o file1 file2 file3 o水平打开多个窗口,O垂直打开多个窗口

4、在窗口之间进行切换:
ctrl+w,w:按住ctrl键,同时按下两次w键,从一个窗口切换到另一个窗口
ctrl+w,l(或->)切换到右侧窗口
ctrl+w,h(或<-)切换到左侧窗口
ctrl+w,k(或上箭头)切换到上方窗口
ctrl+w,j(或下箭头)切换到下方窗口

5、在窗口移动:
ctrl+w,L 将当前窗口移动到右侧窗口
ctrl+w,H 将当前窗口移动到左侧窗口
ctrl+w,K 将当前窗口移动到上方窗口
ctrl+w,J 将当前窗口移动到下方窗口

6、改变窗口大小:
ctrl+w,+/-:按住ctrl键,同时按下w键,然后再按下+(增大窗口)或-(减少窗口)(这时不按下ctrl键)。
{height}CTRL-W, +/- 增加或减小窗口高度
{width}CTRL-W, 增加或减小窗口的宽度

7、关闭当前文件:
(1)将光标切换到当前窗口下,然后按照关闭单个窗口的方法关闭窗口。例如:q命令。
(2)关闭所有窗口文件:在所有关闭单个窗口的命令中加上all,例如:qall命令。
(3)关闭除当前窗口之外的文件。:only。

8、在多窗口下新建文件
:new

9、不同文件比较
:diffsplit file 上下窗口显示
:vertical diffsplit file,左右窗口显示

标签:

给我留言

Copyright © 小小的数据技术梦想 保留所有权利.   Theme  Ality 浙ICP备12043346号-1

用户登录

分享到: