Vim change windows size

Vim change windows size

Very simple vim plugin for easy resizing of your vim windows.

You can resize windows continuously by using typical keymaps of Vim. ( h , j , k , l )
The WindowResize mode makes your operation more quickly and more naturally.

For terminal vim

Window Move mode

You can move windows.

Change the focus & resize window

Focus mode -> Resize mode

For MacVim(gui vim)

  • MacVim Window resize
  • Vim window resize

In default setting

You press keys Ctrl + E or execute :WinResizerStartResize on vim(in normal mode), to run this plugin

Start ‘window resize mode’, and you can resize current vim windows using ‘h’, ‘j’, ‘k’, ‘l’ keys

You want to finish resize mode, then press «Enter» key

If you cancel window resize, then press «q» key. You will get window size of before change

You can change the mode if you press «e» in ‘window resize mode’

You can change setting and key mappings by using below options.(in your vimrc)

variable name default value description
g:winresizer_enable 1 Use winresizer (If this value is 0, this plugin will not work)
g:winresizer_gui_enable 0 Use winresizer in GUI Vim (If this value is 0, this plugin will not work in GUI Vim such as Mac Vim)
g:winresizer_finish_with_escape 1 If this value is 1, window resize mode is finished(fixed) by Esc
g:winresizer_vert_resize 10 The change width of window size when left or right key is pressed
g:winresizer_horiz_resize 3 The change height of window size when down or up key is pressed
g:winresizer_start_key Ctrl + e Start window resize mode
g:winresizer_gui_start_key Ctrl + a Start window resize mode (in GUI Vim)
g:winresizer_keycode_left 104( h ) Expand window size to left
g:winresizer_keycode_right 108( l ) Expand window size to right
g:winresizer_keycode_down 106( j ) Expand window size to down
g:winresizer_keycode_up 107( k ) Expand window size to up
g:winresizer_keycode_focus 102( f ) Change a mode to Focus mode
g:winresizer_keycode_move 109( m ) Change a mode to Move mode
g:winresizer_keycode_resize 114( r ) Change a mode to Resize mode
g:winresizer_keycode_mode 101( e ) Rotate a mode (Resize -> Move -> Focus -> Resize . )
g:winresizer_keycode_finish 13( Enter ) Fix and escape from window resize mode
g:winresizer_keycode_cancel 113( q ) Cancel and quit window resize mode

If you want to resize MacVim window itself, you must set below.

Example in your .vimrc

📝 If you use winresizer with default settings. Don’t have to do any settings.

How To Use VIM Split Screen

Installing VIM

VIM text editor is available on the official package repository of almost all Linux distributions such as CentOS, RHEL, OpenSUSE, Ubuntu, Debian, Linux Mint etc.

For Debian Based Operating Systems

VIM should be installed.

For RPM Based Operating Systems

On RHEL, CentOS, or Fedora, run the following command to install VIM:

Basics of VIM

Once VIM is installed, you can start VIM with the following command:

This is the welcome screen of VIM text editor.

VIM has many modes. The most important ones are “Command Mode” and “Insert Mode”. When VIM starts, you’re in “Command Mode”. In this mode, you run VIM commands to open file, save file, close VIM, search substrings in file and many more.

You can press ‘i’ to switch to “Insert Mode”. In this mode, VIM works like any other text editor. You can press to go back to “Command Mode” from “Insert Mode”.

Opening a File on VIM

To open a file on VIM, you go to the “Command Mode” and then type the following command to open a file.

FILE_PATH can be relative path to the directory where you opened VIM from or full path.

Splitting VIM screen Horizontally and Vertically

To open a new VIM window next to the existing one, press + then press .

Now you can move to the right window from the left by pressing + and then pressing

You can move to the left window again by pressing + and then pressing . To open a new VIM window on the bottom of the currently selected window, press + then press . You currently selected window should be split vertically as shown in the screenshot below.

You can go to the window below the selected window by pressing + and then pressing

You can go to the window above the selected window by pressing + and then pressing

Copy and Paste Texts Between VIM Split Screens

I have 3 different text files opened in 3 different windows on VIM as you can see from the screenshot.

Let’s say I want to copy the text “good text editor” to another VIM window.

To do that, from the “Command Mode”, first go to the location from where you want to start your selection and press to go to the “Visual Mode” of VIM and select the substring and press . The text should be copied.

Now go to another window by pressing + and then any of or depending on your choice. Now go to “Insert Mode” by pressing ‘i’ and navigate to the place where you want to paste the text. Then go back to “Command Mode” by pressing and press

to paste the copied text.

You can see from the screenshot below that the copied text is pasted correctly.

Change the Split Screen Window Size of VIM

There are several shortcuts to change the split screen window size of VIM. You can increase the width of your window by pressing + and then ‘>’ and decrease the width by pressing + and then ‘ + and then press ‘+’ and to decrease the width press + and then press ‘-’.

After increasing the height one of my VIM window, this is how it looks like now:

You can reset to the equal width and height windows by pressing + and then pressing ‘=’ as you can see from the screenshot below.

That’s how you use VIM shortcut keys to use VIM split screen feature, navigate between them, resize them and copy/paste between windows. Thanks for reading this article.

How do I set the default window size in vim?

When I right click on a file and open it in Vim, the default window size is too small. How can I change the settings so that the default window size is bigger?

I’m running Vim 7.3.46 in Windows 7.

2 Answers 2

You can set the ‘lines’ and ‘columns’ options in

/_gvimrc on Windows). E.g:

I don’t recommend you do this in your vimrc, because setting those options in console Vim can have odd effects, if it works at all; the gvimrc is only loaded when gVim is started.

This page suggests adding the following to _vimrc for avoiding problems with console Vim:

Also, this SO question looks at how to remember the previous session’s window size.

Not the answer you’re looking for? Browse other questions tagged windows vim or ask your own question.

Hot Network Questions

Subscribe to RSS

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev 2021.4.16.39093

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

How do I change the current split’s width and height?

I am working on split (using ^w+v, ^w+s) buffers, but sometimes I would like to widen a current split or change its height. How can I achieve that?

6 Answers 6

There are several window commands that allow you to do this:

  • Ctrl+W +/- : increase/decrease height (ex. 20 + )
  • Ctrl+W >/ : increase/decrease width (ex. 30 )
  • Ctrl+W _ : set height (ex. 50 _ )
  • Ctrl+W | : set width (ex. 50 | )
  • Ctrl+W = : equalize width and height of all windows

See also: :help CTRL-W

You can also use the resize commands:

  • :resize [+-]N — resize a horizontal split, increasing or decreasing height by N characters.
  • :vertical resize [+-]N — resize a vertical split, increasing or decreasing height by N characters.
  • :resize N — resize a horizontal split, setting height to N characters.
  • :vertical resize N — resize a vertical split, setting width to N characters.

These are equivalent to the Ctrl w commands. See :help window-resize .

This is one of the few reasons I like to use vim’s mouse mode.

If you use the GUI version, or your terminal supports sending drag events (such as xterm or rxvt-unicode) you can click on the split line and drag to resize the window exactly where you want, without a lot of guess work using the ctrl-w plus,minus,less,greater combinations.

In terminal versions, you have to set mouse mode properly for this to work

(I use ‘n’, but ‘a’ also works)

and you have to set the tty mouse type

A lot of people say that a lot of time is wasted using the mouse (mostly due to the time it takes to move your hand from the keyboard to the mouse and back), but I find that, in this case, the time saved by having immediate feedback while adjusting the window sizes and the quickness of re-resizing (keep moving the mouse instead of typing another key sequence) outweighs the delay of moving my hand.

How can I maximize a split window?

Invoking :help in Vim, I got the help manual page with split window. I want to maximize the help manual window and close the other window.

How can I do this? What is the Vim command to do this?

11 Answers 11

With :help [topic] you open up a topic that interests you.
Ctrl-Wo will minimize the other windows (leaving only the help window open/maximized).
(Ctrl-Wo means holding Ctrl press W, and then o)

You can employ Ctrl+W T (that’s a capital T ) to move any open window to its own tab.

As mentioned by others Ctrl+W _ / Ctrl+W | to maximize within the current tab/window layout (while respecting min height/width settings for various other windows).

( Ctrl+W = resizes all windows to equal size, respecting the minimum height/width settings)

Edit To the comment

  1. start vim (e.g. gvim /tmp/test.cpp )
  2. invoke help :help various-motions — opens a split window
  3. move help into separate tab maximized: C-w T
  4. enjoy reading the fine manual 🙂

move the help back into the original tab:

  • mA: set global mark A
  • ZZ: close help buffer/tab
  • C-w S: split original window
  • ` A: jump to saved mark A

You can avoid using a mark for normal (non-help) buffers. Let me know if you’re interested.

You can expand a window to its maximum size using Ctrl+W _ (underscore). The final size of the expanded window will be constrained by the value of the winminheight option. When you close the help window, your previous window(s) will be restored to their former sizes.

I prefer to use tabs for that. Use

to open a file maximized in a new tab, once you are done return to the old setup with all windows using

I find this the ideal solution as this works together with :cw and the Tagbar plugin. Taken from: vim.wikia

I like to use ‘M’ to maximize and ‘m’ to minimize.

It won’t look great as it’ll shrink all the other open windows that are in the same buffer, but I found it to be more useful when dealing with tabs. So for instance, instead of opening a new tab for that file then having to close it after you’re done with it or want to minimize it.

The reason for nnoremap is that I don’t care about recursive mapping, but just map should also work.

You can get help window in full size without closing/resizing any other windows by using

This will open help window in a new tab, other windows will be left as-is (really resized so that tabline can be shown, but this is only one additional line above). You can close help as usual: at least :bw and c work for me closing new tab as well.

Install the plugin vim-maximizer, then you can maximize the current window and restore with F3

Plugin ZoomWin

by Charles Campbell

This plugin remaps

to do both: maximize and restore previous layout.

This plugin can be downloaded from two locations

Somehow the ZoomWin plugin did not work at all for me, I now see there are other plugins but I already wrote this and gives me the exact effect I wanted (with a minor quirk detailed below):

Use the mapped key (Leader and + in my case) to toggle between maximized / previous layout. If you change to another split in the same tab, maximization turns off.

If you change tabs, the split stays maximized, although somehow it won’t cover the complete full width anymore, with the width minimized windows gaining back some 4 columns or something. Anyway it works acceptably for me even with that minor quirk.

edit: somehow it works fine now, must’ve messed up in some way before.

Читайте также:  Вай фай адаптер для линукс минт
Оцените статью