93 votes

Swap the position of two windows

To swap the two parts of a split window simply do: <C-w> <C-r>
user avatar
  • 1,039
69 votes
Accepted

Close all split files, except the one currently focused?

If you want to close all windows(splits) except the current one: :only If you want to close all tabs except the current one: :tabonly If you want to delete all hidden buffers (files open but not ...
user avatar
  • 2,838
68 votes
Accepted

How to save window, split, and buffer layout?

You can use vim's :mksession and write each "workspace" to a different file, then reopen a session using vim -S session_file, however, if you're open to using a plugin then I find the vim-startify ...
user avatar
  • 2,221
60 votes
Accepted

How to "full screen" browse Vim help?

Just expand the help window to be the only visible window: Ctrlw-o When you're done you can switch back to your other buffers.
user avatar
  • 2,221
53 votes
Accepted

What are the new "popup windows" in Vim 8.2?

Background: I was playing around with Vim 8.2's popups recently (I have a small plugin that allows navigation of sections in a markup document and I was looking at showing section hierarchies in ...
user avatar
  • 18.3k
49 votes

Close all split files, except the one currently focused?

Press Ctrl+w,o to quickly close all split windows, but current one. Alternatively use the command: :on (:only). :on[ly][!] Make the current window the only one on the screen. All other ...
user avatar
  • 16.6k
39 votes
Accepted

How can I work with splits in Vim without Ctrl-W?

You can remap <C-w> to another combination, for example: :nnoremap <C-e> <C-w> You can now use <C-e> and it will act as if you've pressed <C-w>. This will overwrite the ...
user avatar
33 votes

How do you open a new buffer in the current window?

The answer is to use :ene[w] Hah I should have looked at the help before! My first instinct was to try :e without any arguments. I looked at the help for this and a bit further down is :ene[w] ...
user avatar
  • 1,121
31 votes

How to save window, split, and buffer layout?

You can use tpope's vim-obsession plugin to easily manage sessions. It is like a wrapper to Vim's in-built mksession, but provides a set of other niceties as well. You can save the current session (...
user avatar
  • 15.5k
31 votes

How to "full screen" browse Vim help?

Alternatively, you could open the help window in a new tab: :tab help foo, and then use :q to close it.
user avatar
  • 13.6k
29 votes
Accepted

How to apply a setting in all open tabs and windows?

Yes, there is! You can accomplish this with :tabdo and :windo. For your case specifically: :tabdo windo set number See :help :tabdo and :help :windo for more information.
user avatar
  • 7,426
28 votes
Accepted

How do I change the default size of plugin window (NerdTree, Taglist, etc)?

The examples below set the width to 60 columns. Adjust to your preferences. NERDTree NERDTree uses a variable for just this: :let g:NERDTreeWinSize=60 This will set the width to 60. You can put ...
user avatar
  • 8,032
28 votes

Swap the position of two windows

CTRL-W x exchange current window with window N (default: next window) (index.txt section 2.2, "Window commands") If A is the current window, then the next will be B, so ...
user avatar
24 votes

How to "full screen" browse Vim help?

The other answers have already answered your question, but for the sake of completeness: If you just want to temporarily get a larger window for your help-viewing, you can use either or both of the ...
user avatar
  • 27.5k
24 votes

How can I work with splits in Vim without Ctrl-W?

I actually use :wincmd more often than Ctrl+W because I find it easier to type the abbreviated :winc. For example, the equivalent to Ctrl+W L is :winc l.
user avatar
23 votes
Accepted

How do I change the colour of the statusline of the currently focused window?

You can change it in your vimrc. The currently focused window is highlight group Statusline, other windows are StatuslineNC. Example for terminal Vim: hi StatusLine ctermfg=8 ...
user avatar
  • 298
22 votes

How can I make Vim open help in a vertical split?

You can use :vert h [your topic] to open help vertically. You can use the following command: cnoreabbrev H vert h To make vim replace H by vert h automatically in command line. Also you can use ...
user avatar
  • 46.3k
21 votes
Accepted

How to make the two windows equal width when comparing files?

You can equalize the size of windows with <c-w>=.
user avatar
  • 328
20 votes
Accepted

Get the current window/buffer/tabpage in Vimscript

Well… it's just as simple in vimscript. Current window Python: current_win = vim.current.window Vimscript: let current_win = winnr() Current buffer Python: current_buff = vim.current.buffer ...
user avatar
  • 32.8k
20 votes

How to switch between buffer and terminal

A better way which I use (and love these days) to jump between terminal (interactive mode with all alias and path set) and vim is using CTRL+Z in normal mode. Work on terminal, and when done type fg ...
user avatar
18 votes

Send text from one split window to another

Neovim terminal buffers always have an associated job id, so one way is to use the job control API to send the text. Add this to your vimrc: augroup Terminal au! au TermOpen * let g:...
user avatar
18 votes
Accepted

How to repeat a mapping when keeping key pressed

You could try entering a ... Vim submode! For your case, something like this: call submode#enter_with('grow/shrink', 'n', '', '<leader><up>', '<C-w>+') call submode#enter_with('grow/...
user avatar
  • 9,310
18 votes

What is the difference between a tab, viewport, window, split and buffer?

A buffer is the in-memory text of a file. It may differ from the saved version of the file. A window is a view of a buffer. You can have two (or more) windows editing different parts of the same ...
user avatar
  • 2,271
17 votes
Accepted

Send text from one split window to another

Basically when you have text selected, you want to remap a key sequence to copy, switch to terminal, paste, and then possibly switch windows back and reselect the text. If you have two splits open, ...
user avatar
  • 2,838
17 votes
Accepted

How to switch between buffer and terminal

From :h terminal-typing CTRL-W can be used to navigate between windows and other CTRL-W commands, e.g.: CTRL-W CTRL-W move focus to the next window CTRL-W : enter an Ex command
user avatar
  • 1,076
16 votes

How to save window, split, and buffer layout?

As a side note, I'd like to point out that I built yet another plugin dhruvasagar/vim-prosession as an extension to tpope/vim-obsession that enhances it even further to create & manage vim ...
user avatar
  • 5,195
16 votes
Accepted

Vertical equivalent of "control+w n"?

From :help vnew: Like |:new|, but split vertically. If 'equalalways' is set and 'eadirection' isn't "ver" the windows will be spread out horizontally, unless a width was ...
user avatar
  • 5,826
16 votes
Accepted

Move existing window to existing tab

Though there are commands to move existing windows around in the current tab page (i.e. affect the window layout by rotating, resizing, and moving), there are no commands to move a window to another ...
user avatar
  • 16.7k
16 votes

What is the order of WinEnter, BufEnter, BufRead, Syntax, FileType events?

To complete the @sundar answer: You can log the order of the events simply with a logging function: augroup EventLoggin autocmd! autocmd BufNewFile * call s:Log('BufNewFile') autocmd BufReadPre *...
user avatar
  • 15.2k

Only top scored, non community-wiki answers of a minimum length are eligible