Questions tagged [vim-windows]
A Vim window is a view of a buffer. A tab page comprises one or more windows. For questions about interaction with the Microsoft operating system, use [microsoft-windows]. For questions about interaction with the desktop windowing system, use [window-management].
521
questions
248
votes
6
answers
191k
views
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?
130
votes
5
answers
199k
views
Is it possible to split Vim window to view multiple files at once?
When working with multiple files, it would be very handy if we can see more than one file in the screen at once. Is there any way in Vim to split the window (horizontally or vertically) so each split ...
90
votes
7
answers
50k
views
Swap the position of two windows
Say the following is the current structure of my window:
+-----+----------------------------
| |
| A |
| |
+-----+
| |
| B |
The order of A and B is not quite natural. It would be ...
87
votes
1
answer
38k
views
How to open multiple files in split mode?
I know how to split windows in vim, but it's possible to open multiple files using vim in split mode (at startup) from the command line?
In example:
vim file1 file2 file3
or:
vim *.cpp
78
votes
4
answers
29k
views
How to save window, split, and buffer layout?
I have several tasks I am working on in one repository. I would like to create "workspaces" for working on them.
One "workspace" or "buffer layout" would have all files I need to work on open in the ...
67
votes
17
answers
27k
views
How to "full screen" browse Vim help?
I know I can browse Vim help with :help, but this opens a split. Sometimes, I just like to study documentation. How can I read the Vim documentation in a "full screen" mode?
60
votes
2
answers
19k
views
Close all split files, except the one currently focused?
Sometimes when I'm working on a file, I'll open up multiple files just to get an idea of the current flow of the code up to a point. However this sometimes leads to multiple files being open at a time ...
50
votes
2
answers
24k
views
Can I open a new vim split from an existing buffer?
I know it's possible to open a new file in a split, with :split or :vsplit, but is it possible to open a new split with an existing buffer, potentially leveraging autocomplete?
47
votes
4
answers
31k
views
How can I work with splits in Vim without Ctrl-W?
My terminal doesn't allow me to type Ctrl+W, because that's a shortcut for closing a terminal tab.
I like working with splits, but I can't find any way to do so without using C-W. This forced me to ...
40
votes
1
answer
14k
views
What are the new "popup windows" in Vim 8.2?
The latest version of Vim, 8.2, has a new feature called "popups" or "popup windows". They sound interesting but I'm not quite sure what they're good for. Can you enlighten me...preferably with some ...
39
votes
6
answers
8k
views
How to undo/revert making current window the only window (":only" / "<C-W> o")?
Consider a case with multiple splits in a window. vim allows quickly "maximizing" the current split to take up the whole window via <C-W> o.
Is there a way get vim to "remember&...
37
votes
3
answers
24k
views
In Vimdiff, how do I switch the left and right panes?
When I do vimdiff file2 file1, file2 naturally goes on the left and file1 on the right.
Sometimes I find that I put them the wrong way round, so I'd like to be able to switch them round without ...
35
votes
1
answer
11k
views
How do you open a new buffer in the current window?
I've got a few tabs open with different window setups.
I'd like to open a new blank buffer in the current window, without having any more splits/windows or tabs
Is there any way to do this?
I know ...
34
votes
3
answers
6k
views
How to apply a setting in all open tabs and windows?
Is there an option to apply a setting in all tabs and windows, e.g. apply :set number to all open tabs?
33
votes
3
answers
12k
views
What is the order of WinEnter, BufEnter, BufRead, Syntax, FileType events?
I've gone through the autocmd.txt help, but the information about this is scattered and not always present (eg. with BufRead).
Could someone who understands this well list the order of these events -...
30
votes
2
answers
12k
views
How do I open a new buffer without opening it in a split?
I know I can use :new to open a new buffer in a split window (defined by set splitbelow and set splitright).
But how can I just open a new, empty buffer without opening it in a split?
30
votes
1
answer
7k
views
How can I get both splits to scroll left or right at the same time?
I want to open up two different parts of a document in horizontal splits (using :sp) and scroll both of them left and right together. For vertical scrolling, you would use scrollbind. However, I'm not ...
28
votes
3
answers
15k
views
Can the split separator in vim be less than a full column wide?
I use a tiling window manager (awesome) + a terminal multiplexer (tmux) + splits inside of vim. I have no window decorations at all, so there is no visual split between them at all if the content of ...
28
votes
2
answers
8k
views
Make panes resize when host window is resized
I like to use vimdiff as a git diff/merge tool. The problem is when I resize the host terminal window to a new size: of the two split panes, the leftmost remain of the same width, while the rightmost ...
28
votes
5
answers
8k
views
How can I make Vim open help in a vertical split?
I usually work in a drop-down terminal, running about 25 characters high. Since I prefer tabs to windows1, usually a lot of horizontal space is wasted - around half of the terminal width.
On top of ...
28
votes
7
answers
8k
views
Move existing window to existing tab
Sometimes I need to move windows into an already existing tab, and I was wondering if there was a command/keyboard shortcut that could do this. I know I can close the window, switch to the tab, and ...
24
votes
6
answers
23k
views
What is a scratch window?
Sometimes I see a window open with name scratch.
I know it is some kind of temporary buffer/window.
How can I create one?
:h scratch returns nothing.
24
votes
2
answers
24k
views
How do I change the default size of plugin window (NerdTree, Taglist, etc)?
I'm using the Taglist and NerdTree plugins quite often. Usually the window that opens in the left side is too small and I need to extend it.
I usually do: 10 CTRL+w >
Is there a way to change the ...
24
votes
1
answer
9k
views
How do I get the actual height and width of Vim?
winheight() and winwidth() return the number of columns/lines in the current window. What I'm looking for is something closer to the actual height and width of the editing area, or displayed area if ...
22
votes
5
answers
40k
views
How to switch between buffer and terminal
I have a vim's buffer and a terminal in the same vim's window but each time switch to terminal I can only exit it to go back to vim's buffer,
Is there a way to keep terminal session but be able to ...
21
votes
2
answers
7k
views
How to exit Vim from split mode?
How to efficiently exit Vim when editing multiple files in the split mode at one go?
It seems when I'm having e.g. 10 split windows, I've to repeat 10 times :q! command for each window which is a bit ...
20
votes
3
answers
24k
views
How to map two commands with only one key
My question comes from this two commands I added on my _vimrc file:
nnoremap <C-[> :set columns+=1<CR>
nnoremap <C-]> :set lines+=1<CR>
As is known, it will resize your gvim (...
20
votes
1
answer
10k
views
Get the current window/buffer/tabpage in Vimscript
In python, when using the vim module, it is incredibly simple to get the current window/buffer/tabpage:
current_win = vim.current.window
current_buff = vim.current.buffer
current_tabpage = vim....
19
votes
4
answers
6k
views
Send text from one split window to another
Recently there was an add-on to NeoVim which allows opening terminal in a vim buffer. This has appealing possibilities to send text from one vim window to another replicating, for example, a REPL like ...
19
votes
2
answers
3k
views
How to make the two windows equal width when comparing files?
How to make the two windows equal width when comparing files with command
vim -d file1 file2?
How to make the two windows be equal width?
18
votes
1
answer
9k
views
How do I change the colour of the statusline of the currently focused window?
How do I change the colour of the statusline of the currently focused window?
I've seen colorschemes modify this. Is this some sort of highlight group? Or something else?
18
votes
2
answers
5k
views
How to repeat a mapping when keeping key pressed
I have in my .vimrc some simple mappings to resize split windows easily:
noremap <Leader><UP> <C-w>+
noremap <Leader><DOWN> <C-w>-
That works pretty fine but ...
18
votes
1
answer
2k
views
What is the difference between a tab, viewport, window, split and buffer?
What is the difference between the following in vim:
buffer
window
viewport
split
tab
17
votes
7
answers
4k
views
How to bind a set of buffers to a tab?
When I need to work on different projects at the same time I have the folowing workflow:
I create one tab for each project.
In each tab I open the files that I want to edit, which makes several ...
15
votes
3
answers
1k
views
How can I get my windows back into a grid formation?
If I have windows arranged into four quadrants, as from the following sequence of commands:
:tabnew
:vsplit
:split
<C-W>l
:split
then entering a command like <C-W>J will cause these to ...
15
votes
1
answer
2k
views
Vi and Vim default to split left and split above. What is the history and motivation behind this?
When a window is split, given that Vi/Vim splits are not stored in a tree structure, the "direction of the split" is basically "the window in which the cursor is placed after the ...
13
votes
3
answers
7k
views
Is it possible to have the output of a :! command in a split rather than the whole window?
If I have a vim session with two splits, when I execute a :! command, the result is shown in the entire window. Is it possible to have the output shown just on the active split?
13
votes
1
answer
3k
views
How should the option 'switchbuf' work?
I recently discovered the option switchbuf and tried to use it but I can't say if I don't understand how it should work or if it actually doesn't work on my Vim.
About the different possible values, ...
13
votes
2
answers
1k
views
Is it possible to tell if a window is at bottom or top, left or right?
I don't know if there's some function to check a window's position, I mean is it currently sitting at bottom or top, left or right??
__________________________
| | |
| |...
12
votes
1
answer
928
views
How do I stop my window from moving when using vsplit?
When using :vsplit my gvim window jumps to a specific screen location. How do I stop this from happening?
Same thing happens when the second to last split is closed.
I'm using gvim on Windows.
11
votes
3
answers
6k
views
How can I open a buffer in a new tab leaving the current window and buffer intact?
Often when coding I have this window layout - which is mapped to the flow of the program I am editing.
Tab1
+------------+--------------+
| | |
| | B |...
11
votes
2
answers
3k
views
How to lock a window height / width?
I jot notes in a tiny split window (buffer) regularly:
<C-W>s
:enew
:res 5
... jot jot...
When I create a new horizontal split in the same tab, that little window resizes, as if doing <C-W&...