开发者

How do I repeat the "resize window" command in vim?

I know how to resize a window (CTRL_W +). But when I want to repeat the same command, . is useless. Typing CTRL_W + repeatedly is boring. Is there anything else I can do?

In my system:

if bufwinnr(1)
  map + <C-W>+
  map - <C-W>-
endif

does not work.

if bufwinnr(1)
  map <kPlus> <C-W>+
  map <kMinus> <C-W>-
  map <kDivide> <c-w><
  map <kMultiply> <c-w>&g开发者_运维技巧t;
endif

does work.


I'd recommend the mapping of + and - key like this (in your .vimrc):

if bufwinnr(1)
  map + <C-W>+
  map - <C-W>-
endif    

And please read this, there are several good tips: http://vim.wikia.com/wiki/Fast_window_resizing_with_plus/minus_keys


The Ctrl-W+ shortcut takes a preceding count. The Ctrl-W_ command maximizes the window without a count, or sets absolute height with a preceding count. Using counts, you should rarely have to do repeated window resizing commands.

If you do find yourself frequently wanting to make small repeated adjustments to window sizes, maybe you could take advantage of the repeatability of ex-commands (with @:) and resize with :resize +1 instead of the keyboard shortcut. If you resize windows all the time, I'd go with mapping the + and - as Zsolt suggested. If you are just restoring the same window layout over and over, look into using a saved session file (:help sessions).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜