> ## Content Index
> Fetch the complete content index at: https://linuxhandbook.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Using Split Windows With Vim
- URL: https://linuxhandbook.com/vim-split-windows/
- Published: 2025-05-21T10:46:09.000Z
- Updated: 2025-08-23T03:13:05.000Z
- Description: Vim allows you to use multiple windows in the same terminal screen. You can split them horizontally and vertically and move between them with shortcuts.
- Author: Abhishek Prakash
- Tags: Vim Tips, #docs-col, Advanced Vim Concepts, #group-advanced-tips

Have you ever watched a bearded sysadmin navigate their editor with lightning speed, jumping between multiple panes with the flick of a few keystrokes? That's the magic of Vim's split window feature! 

Think of it as having multiple monitors inside a single screen. And you don't even need [screen command](https://linuxhandbook.com/screen-command/) or [tmux](https://linuxhandbook.com/tmux/) tools for this purpose. Vim does it on its own. 

![One Vim instances with three window splits.](https://linuxhandbook.com/content/images/2025/05/vim-split-window.png)

Split Windows in Vim Editor

You can split the screen horizontally as well as vertically. And all this is done with a few keystrokes, of course.

## Vim split window keyboard shortcuts

| Action                   | Keyboard Shortcut | Description                          |
| ------------------------ | ----------------- | ------------------------------------ |
| Horizontal split         | :split or :sp     | Splits window horizontally           |
| Vertical split           | :vsplit or :vs    | Splits window vertically             |
| Close current window     | :q or :close      | Closes the active window             |
| Close all except current | :only or :on      | Closes all windows except active one |
| Navigate between windows | Ctrl-w + h/j/k/l  | Move to left/down/up/right window    |
| Navigate between windows | Ctrl-w + Ctrl-w   | Cycle through all windows            |
| Resize horizontally      | Ctrl-w + < or >   | Decrease/increase width              |
| Resize vertically        | Ctrl-w + - or +   | Decrease/increase height             |
| Equal size windows       | Ctrl-w + =        | Make all windows equal size          |
| Maximize height          | Ctrl-w + \_       | Maximize current window height       |
| Maximize width           | Ctrl-w + \|       | Maximize current window width        |
| Move window              | Ctrl-w + r        | Rotate windows                       |
| Swap with next window    | Ctrl-w + x        | Exchange with next window            |

You can also use the mouse for resizing and some other features if you [have mouse enabled in Vim](https://linuxhandbook.com/vim-mouse-mode/).

[Using Mouse Mode in VimThink of mouse mode in Vim like adding touchscreen controls to a cockpit - the physical switches and dials remain the primary interface, but the touchscreen provides intuitive access for certain operations.![](https://linuxhandbook.com/content/images/icon/Linux-Handbook-New-Logo-78.png)Linux HandbookAbhishek Prakash![](https://linuxhandbook.com/content/images/thumbnail/use-mouse-mode-vim.png)](https://linuxhandbook.com/vim-mouse-mode/)

## Creating Split windows

Let's see in details about how those magical keys work and look like in the editor.

### Horizontal splits

Creating a horizontal split in Vim is like adding a floor to your house - you're stacking views on top of each other. 

When you're deep in code and need to reference something above or below your current focus, horizontal splits come to the rescue.

```
:split filename  (or :sp filename)

```

0:00 

/0:11 

1× 

Horizontal split in action

Filename is optional here. If you don't specify a filename, Vim will split the window and show the current file in both panes.

💡

Use `:set splitbelow` to open the new windows below the current one.

### Vertical splits

Vertical splits open windows side-by-side. It's good for viewing documentation, or keeping an eye on multiple parts of your project. You can also use it for quickly comparing two files if you do not want to use the dedicated [vimdiff](https://linuxhandbook.com/vimdiff/).

```
:vsplit filename  (or :vs filename)

```

0:00 

/0:12 

1× 

Vertical split in action

💡

By default, the new windows are opened on the left of the current window. Use `:set splitright` to open the new windows on the right.

## Moving between split windows

Once you've created splits, hopping between them is where the real productivity starts. Think of `Ctrl-w` as your magic wand - when followed by a direction key, it teleports your cursor to that window.

- `Ctrl-w` followed by `w` will switch to the below/right window.
- `Ctrl-w` followed by `W` (uppercase W or Shift-w key) will switch to the above/left window.

I prefer the direction keys, though. It is easier to navigate this way in my opinion.

```
Ctrl-w h  # Move to the window on the left
Ctrl-w j  # Move to the window below
Ctrl-w k  # Move to the window above
Ctrl-w l  # Move to the window on the right

```

0:00 

/0:15 

1× 

Move between splits

You can also use the arrow keys instead of the typical hjkl [Vim movement keys](https://linuxhandbook.com/vim-move-around/).

💡

If remembering directions feels like a mental gymnastics routine, just cycle through all the windows by pressing `Ctrl-w` `Ctrl-w`. Pressing them multiple times in pair and you'll move from one split window to the next.

I'll be honest - when I first started using Vim, I kept forgetting these window navigation commands. So, I thought of `Ctrl-w` as "window" followed by the direction I wanted to go. After a few days of practice, my fingers remembered even when my brain forgot!

## Resizing split windows

Not all windows are created equal. Some need more space than others, based on your need. Vim lets you adjust your viewing space with a few keystrokes.

```
Ctrl-w +  # Increase height by one line
Ctrl-w -  # Decrease height by one line
Ctrl-w >  # Increase width by one column
Ctrl-w <  # Decrease width by one column

```

0:00 

/0:21 

1× 

Resize split windows

For faster resizing, prefix these commands with a number:

```
10 Ctrl-w +  # Increase height by 10 lines

```

**When things get too chaotic**, there's always the great equalizer:

```
Ctrl-w =  # Make all windows equal size

```

Just so that you know, you can also create splits with specific dimensions by adding a number before the command. 

For example, `:10split` creates a horizontal split with 10 lines of height, while `:30vsplit` creates a vertical split that's 30 characters wide.

💡

Need maximum space ASAP? Try these power moves:  
  
`Ctrl-w _` maximizes the current window's height   
`Ctrl-w |` maximizes the current window's width  
`Ctrl-w =` equalizes all windows when you're ready to share again  
  
I call this the "focus mode toggle" - perfect for when you need to temporarily zoom in on one particular section of a file!

## Moving and rearranging Windows

Sometimes you create the perfect splits but realize they're in the wrong order. Rather than closing and recreating them, you can rearrange your windows like furniture:

```
Ctrl-w r  # Rotate windows downward/rightward
Ctrl-w R  # Rotate windows upward/leftward
Ctrl-w x  # Exchange current window with the next one

```

0:00 

/0:28 

1× 

Rearrange split windows

You can also completely move a window to a new position:

```
Ctrl-w H  # Move current window to far left
Ctrl-w J  # Move current window to very bottom
Ctrl-w K  # Move current window to very top
Ctrl-w L  # Move current window to far right

```

It's like playing Tetris with your editor layout. While I am a fan of the classic Tetris game, I am not a fan of moving and rearranging the windows unless it is really needed.

## 💡 Few random but useful tips

Let me share a few more tips that will help your workflow when you are dealing with split windows in Vim.

### Add terminal in the mix

If you are in a situation where you want to look at your code and run it at the same time, like an IDE, you can add a terminal in your split. No more alt-tabbing between terminal and editor!

- `:sp | terminal` opens a horizontal split with a terminal
- `:vs | terminal` opens a vertical split with a terminal

![](https://linuxhandbook.com/content/images/2025/05/terminal-at-the-bottom.png)

Terminal is split window in Vim

### Start split with Vim

Want to start Vim with splits already configured? You can do that from your command line:

```bash
# Open two files in horizontal splits
vim -o file1 file2

# Open two files in vertical splits
vim -O file1 file2

# Open three files in horizontal splits
vim -o3 file1 file2 file3

```

### File explorer in split windows

One of my favorite tricks is opening Vim's built-in file explorer ([netrw](https://www.vim.org/scripts/script.php?script%5Fid=1075&ref=linuxhandbook.com)) in a split:

```
:Sexplore  # Open file explorer in horizontal split
:Vexplore  # Open file explorer in vertical split

```

![](https://linuxhandbook.com/content/images/2025/05/file-explorer-on-left.png)

Vim file explorer in split window

It's like having a mini file manager right next to your code - perfect for quickly navigating project files without losing your place in the current file.

### Close all the split windows and exit Vim

When you are done with your tasks on a project, instead of closing individual split windows, you can close all of them together and exit Vim `:qa`

Save your work before, of course.

## Wrapping up

On a related note, you may also want to [learn about tabs feature of Vim](https://linuxhandbook.com/vim-tabs/). Tabs combined with split windows give you an even more organized workflow in Vim.

[Using Tabbed Interface in VimGive Vim and IDE touch by using tabs to open multiple files. Yes, the same tab experience you have in a web browser or a regular text editor.![](https://linuxhandbook.com/content/images/icon/Linux-Handbook-New-Logo-82.png)Linux HandbookAbhishek Prakash![](https://linuxhandbook.com/content/images/thumbnail/vim-tabs-2.png)](https://linuxhandbook.com/vim-tabs/)

Splits aren't just a cool feature - they're a strategic tool. You can use it to edit files with reference doc open on the side or to watch log output in the terminal while debugging. It's up to you how you use this amazing feature.

It might seem like keyboard gymnastics at first, but quickly becomes second nature. Like learning to touch type or ride a bike, the initial awkwardness gives way to fluid motions that you'll hardly think about.

Start small - maybe just two vertical splits - and gradually incorporate more commands as you get comfortable. Before long, you'll be that expert terminal dweller others watch in amazement as you effortlessly dance between multiple files without ever touching your mouse. Happy splitting! 🚀