66

To swap the two parts of a split window simply do: <C-w> <C-r>


58

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 plugin is exactly what I need for this sort of scenario. It does a great job of managing sessions, in vim and mccvim, and it gives you a list of recent files as ...


52

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 visible in any window on any tab), you'll have to add a function to your vimrc. Some people have posted possible functions to here and here I'm not sure exactly ...


47

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.


37

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 windows are closed. See also: How to convert all windows into horizontal, vertical or tab splits? at Vim SE How to cancel splitted windows? at stackoverflow SE Is ...


34

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 popups). I figured the info I collected would make a decent introduction... Overview Vim 8.2's popup windows allow Vimscript authors and plugin developers to ...


29

You can just 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 default <C-e> mapping (scroll down). Vim already uses every key on the keyboard, and the only way to prevent this is using the leader key, which ...


28

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] Edit a new, unnamed buffer. This fails when changes have been made to the current buffer, unless 'hidden' is set or 'autowriteall' is set and the file can be ...


26

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 (or buffer layout) by giving the command :Obsession. If you don't supply an argument, it writes a session file called Session.vim by default. To reload a ...


24

Alternatively, you could open the help window in a new tab: :tab help foo, and then use :q to close it.


23

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 this line into your vimrc. Taglist For taglist, you set a similar option: :let g:Tlist_WinWidth=60 Like with NERDTree, you can put this line into your vimrc. ...


22

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 ctermbg=2 cterm=NONE hi StatusLineNC ctermfg=2 ctermbg=8 cterm=NONE For the GUI, use guifg and guibg.


21

You can equalize the size of windows with <c-w>=.


19

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 Vimscript: let current_buff = bufnr("%") Current tabpage Python: current_tabpage = vim.current.tabpage Vimscript: let current_tabpage = tabpagenr() See :...


18

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:last_terminal_job_id = b:terminal_job_id augroup END Which will save the the job id of the last created terminal into the g:last_terminal_job_id variable. Then you can ...


18

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 this abbreviation: cnoreabbrev HR vert bo h To open the help window on the right side of the screen. (see :h :botright for more details on bo)


18

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.


17

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 Ctrl-w _ and Ctrl-w | mappings to maximise the help window as much as possible vertically or horizontally, respectively, but without closing your existing split ...


16

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, this would look something like: vnoremap <F5> y<c-w>wp<c-w>pgv "explanation: xnoremap <F5> Remap F5 in visual/select ...


16

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 you only need <C-w> x If B is the current window (and there are more windows below) then you'll first have to go to A, then exchange: <C-w> k <C-...


16

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.


15

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/shrink', 'n', '', '<leader><down>', '<C-w>-') call submode#map('grow/shrink', 'n', '', '<down>', '<C-w>-') call submode#map('grow/...


15

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 buffer. A viewport is synonymous with a window. A tab page contains one or more windows. You can see what windows are in which tab with :tabs. A split is where ...


14

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 sessions by default in a centralised repository as per configuration on a per directory basis and loads them automatically when you launch vim without any arguments on ...


14

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 * call s:Log('BufReadPre') ... autocmd User * call s:Log('User') augroup END function! s:Log(eventName) abort silent execute '!echo '.a:eventName.' >...


13

Another option could be to open your current window in a new tab, then simply close the tab when you're done. The :split (or :sp for short) command, without an argument, has the effect of opening a new split with the same buffer as the current split. The :tab command can run many window-related commands, changing them to use a tab instead. Combining these ...


13

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 specified. However, it seems like Vim does not provide a mapping for :vnew which creates a new blank vertical split. It's easy to create this mapping yourself. For instance: ...


13

I tried googling for this with different sets of keywords, and struck gold on one such attempt with this result: http://www.ibm.com/developerworks/library/l-vim-script-5/ Specifically, this part is relevant to the current question: For example, if you start Vim, edit a file named demo.txt, swap into Insert mode, type in some text, save the file, and then ...


13

This happens because when vertical splitting the window, vim needs to add a vertical scrollbar, which causes vim to recalculate the visual size and eventually makes vim jump to a different screen location. The current workaround is to :set guioptions-=r guioptions-=L Update As of patch 8.0.1278, you can also use :set guioptions+=k to prevent Vim from ...


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