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].

Filter by
Sorted by
Tagged with
60
votes
4answers
13k 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 ...
36
votes
5answers
16k 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 ...
34
votes
2answers
10k 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 ...
27
votes
4answers
11k 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 ...
24
votes
1answer
7k 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 ...
23
votes
9answers
7k 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 read documentation in a "full screen" mode?
18
votes
4answers
3k 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 ...
18
votes
1answer
6k 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
1answer
4k 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 ...
17
votes
4answers
4k 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 ...
17
votes
2answers
2k 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?
16
votes
2answers
1k 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?
16
votes
2answers
4k 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 -...
14
votes
2answers
10k 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 ...
14
votes
6answers
2k 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 ...
13
votes
4answers
2k 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 ...
13
votes
2answers
716 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
1answer
722 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
12
votes
3answers
701 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 ...
11
votes
1answer
4k 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....
11
votes
2answers
2k 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 ...
11
votes
3answers
5k 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?
11
votes
1answer
707 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.
9
votes
3answers
6k 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 crate one? :h scratch returns nothing.
9
votes
1answer
430 views

Why does :bd # delete the current buffer when no alternate buffer exists?

Here is how I reproduce the behavior I am observing. First, I enter this command: echo aaaaa > a vim a In Vim, I enter these commands: :ls :e # :echo bufname('#') Here is the output of the ...
9
votes
1answer
967 views

Buffers vs tabs vs arglist vs windows

So many choices! So confusing! When should one be used in preference to another? How do these relate to each other? What are the differences between them, anyway? How do they affect commands you ...
8
votes
5answers
1k views

Stop CtrlP from opening in NERDTree

I use both CtrlP and NERDTree in my Vim. When I open a file using the CtrlP search feature, it sometimes opens in the NERDTree window (and always if the NERD window is the active one). How can I stop ...
8
votes
1answer
2k views

How to preview the result of markdown file edited in vim?

I use vim to edit latex, but latex is bit too heavy for taking notes casually on daily basis, so I decided to use markdown instead. So, I want to configure vim so that I could view markdown ...
8
votes
4answers
790 views

Switching .c/.h buffers

I normally work with 2 windows, vertically split. The problem I would like to solve, is: easily jumping back and forth from header <-> implementation file I'm investigating, without luck, 2 ways ...
8
votes
1answer
2k views

Open quickfix in vertical split

If I use the command :copen the quickfix buffer will be opened as a horizontal split. Is there a way (a command) to open it in a vertical split instead?
7
votes
4answers
2k views

How to convert all windows into horizontal, vertical or tab splits?

It is possible to convert all windows into different split mode while editing? Instead of one by one? In example (having multiple windows) from horizontal to vertical split and opposite, or from tab ...
7
votes
1answer
1k views

How can I move windows from a vertical split to a horizontal split?

I have three vertically split windows. I want the leftmost window to remain as it is, but move the two other windows from a vertical to a horizontal split. How can I achieve this? I want to get from ...
6
votes
1answer
1k views

Vertical equivalent of “control+w n”?

I often want a new empty vertical pane (vim window / viewport ...) in my current Vim tab. I know I can get a new empty horizontal pane by doing control+w n. I know I can split the current pane into ...
6
votes
3answers
535 views

Detect if window has neighbour in given direction

Is there a robust way to detect whether a window has a neighbour in a given direction? So far, the only solution I found uses wincmd, let winnum = winnr() noautocmd wincmd h if winnum != winnr(...
6
votes
3answers
833 views

How do I switch between the command-line history and file panes?

When using the command-line history window, I'd like to go back to the file I use it on to see what I'm working with. When revisualizing a block of code (gv), the cursor will go to the top after ...
6
votes
2answers
407 views

Keep windows reference in memory

I am writing a plugin which needs to have two windows displayed at the same time: _______ | | | | A | B | |___|___| I need to keep in memory a reference to those windows as I execute my plugin. ...
6
votes
2answers
1k views

If I split the screen and open a Netrw dir listing in one window, Vim won't let me focus that window

I'm using Vim 7.4. I have a buffer open and I type :vsplit. Vim splits the screen and I see my buffer in both windows. That's great. Just what I want. And at this point ctrl+W W switches the focus ...
6
votes
0answers
387 views

Persistently fix the height of a split in vim

So I searched the web far and wide and I can not for the life of me figure out how to do this. I have the following key binding: nnoremap <leader>o :below 10sp term://.//$SHELL <cr> :set ...
5
votes
3answers
2k 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 |...
5
votes
2answers
285 views

Is there a direct way to select the buffer displayed in a non-active window?

I usually have two windows open, one in which I'm working and one in which I'm viewing some information (compiler messages, relevant library headers, etc. etc.). Now, it's easy to switch the buffer on ...
5
votes
1answer
320 views

Emacs switch-window for vim

There is an emacs plugin called switch-window which indexes all open windows and allows the user to switch a window based on it's number. This is really convenient when you have a large number of ...
5
votes
1answer
896 views

Define active window for startup in .vimrc

I have the following line in my .vimrc to open NERDTree on startup: NERDTreeToggle Now, if I start vim, I have NERDTree on the left and the file I opened on the right. The left window is focused on ...
5
votes
1answer
125 views

Can you increase the span of a window?

Let's say I have a window layout like below: [1][2] [3..3] And I want to expand window 2 to look like this: [1][2] [3][2] So window 2 will now be full height
5
votes
2answers
3k views

Can I move my current tab to a split in a different tab?

This happens to me semi-frequently. I have two tabs open, and I would like to merge them into one tab with a vertical split. Essentially, I want to do the opposite of CTRL-w_T. Right now, I have to ...
5
votes
3answers
3k views

How do I automatically size a window?

I often program with lines no more than 80 characters long. I start with an 80-character-wide terminal, but sometimes due to a plugin runs or after creating a vsplit results in the editing area being ...
4
votes
3answers
2k views

How to open a file from active buffer into a split window?

I have some files in my vim buffer. :ls shows the list of active buffer, I want to open a file from buffer into a vertically/horizontally split window. I know :vsp or :sp open split window in vim ...
4
votes
1answer
1k views

How to switch between syntastic error window and editor window

I am new to vim and currently learning as well. I just started using syntastic in vim to lint my code. I have set following vars in my .vimrc file: let g:syntastic_always_populate_loc_list = 1 let g:...
4
votes
1answer
673 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&...
4
votes
4answers
2k views

How to disable moving the cursor with the mouse

I've been using Vim for decades (and Vi before it since around 1984.) I use it now on Linux. Somewhere along the line one behavior crept in that I'd like to disable: when I click in a window to move ...
4
votes
1answer
1k views

What is a better way to use `windo` without changing of window?

In my vimscripts I sometimes have to use the windo command to execute an action on each open split. The problem with this command is that it cycles through all the open splits and ends on a different ...