16
votes
Accepted
Vim hide buffer like in emacs?
By default, Vim will refuse to replace the current buffer with another one if it contains unsaved changes. You'll need to add the option below to your vimrc if you don't want that behavior (and you ...
11
votes
Accepted
Is it possible to open a tab in a window and not a window in a tab?
From :h tab-page-intro:
A tab page holds one or more windows. You can easily switch between tab
pages, so that you have several collections of windows to work on different
things.
Usually ...
7
votes
Is it possible to open a tab in a window and not a window in a tab?
No you can't, here's why:
Vim use multiple concepts to handle text files:
Buffer: An in-memory version of a file. Editing a file will in fact edit the buffer before writing (i.e. saving) anything to ...
7
votes
Accepted
Parsing winlayout() For Toggling Multiple Windows At Once
Full restore
If you want to restore layout with multiple termina buffers, you must restore other windows and buffers too, so it's in fact a full buffer layout restore, it's usage is not limited to ...
4
votes
Vim hide buffer like in emacs?
Close window: Ctrl-w c
Close all other windows: Ctrl-w o, (o for "only")
For more information open vim and enter the command :help window. Look particularly at sections 3 and 4.
4
votes
Accepted
How can I reorient this window arrangement?
With the windows arranged as in you last illustration, move the cursor to window 3 and type <C-W>J.
3
votes
Is there a way to resize a split such that it exactly fits its content (plus/minus N lines of buffer-space)?
Yes.
:execute 'resize' line("$") + 5
3
votes
Accepted
What is the use case of vim Ctrl+w s?
Having multiple views of the same buffer allows you to quickly compare or copy-and-paste without moving back and forth, as @RudyB's answer explains.
Another use case is the opening of another file; ...
3
votes
Accepted
Shell running inside vim windows
You need Vim 8.1, then you can use the following command:
:below terminal ++rows=10
Normally a terminal is opened above the current window, but with below it is opened at the bottom. And in this ...
3
votes
Accepted
Vpslit - open on the right side of session instead of left?
Put the following in your vimrc:
set splitright
Read :h splitright for more information.
3
votes
Quit a window by its win_getid() identifier?
You can retrieve the window number (as opposed to the window ID) and then use wincmd to close:
let winnr = win_id2win(og)
if winnr > 0
execute winnr.'wincmd c'
endif
Keep in mind this won't ...
3
votes
How to map two commands with only one key
I was mapping two commands to one F-key to execute 2 plugin commands and none of the above worked for me.
The only option that worked for me was with to <CR>:
nnoremap <F10> :Doctest <...
2
votes
Accepted
How do I evenly distribute GVim windows started from a key-binding?
It appears as though your needs may be met by using tabs. See :help tabpage in Vim for general help, but here are a few relevant commands:
Start Vim with vim -p filename ... to open each file in a ...
2
votes
quickfix window and location list open at the same time causes weird resize
Unfortunately there is no easy way to fix this at the moment, the OP has opened a vim-go issue and we agree that this is something vim-go can do better. Now we just need someone to spend time fixing ...
2
votes
How to manage windows properly
I don’t use NERDTree myself, but reading the documentation it looks like you want the s map, which opens the selected file in a new vertical split. You may also need to add set splitright to your ....
2
votes
Setting 'viewdir' does not work with :mkview
My problem here is caused by my single quote in viewdir
So I removed it and it's ok.
2
votes
Accepted
Redirect output to a persistent window that respect window layout
Remove :botright as it does:
:bo[tright] {cmd}
Execute {cmd}. If it contains a command that splits a window,
it will appear at the bottom and occupy the full width of the
Vim ...
1
vote
Accepted
Forcing integrated terminal to scroll down after relayed command
If you have the window ID then win_execute({winid}, {command}) should be useful. It is like execute() but operates in the context of the specified window.
Something like:
:call win_execute({winid}, '$'...
1
vote
Is it possible to save/restore just window layout (no buffers etc.)?
A window cannot exist without any buffer attached.
Just make sure you have an empty unnamed buffer in every window and save the session.
1
vote
How to open netrw at each vim session but have the cursor on the code (and not on the tree) when opening
You can add a second VimScript command to be executed after :Vexplore.
Here wincmd w is equivalent to the <Ctrl+w>w key combination which toggles windows (see Vim documentation: windows).
...
1
vote
Accepted
How to manage windows properly
Nerdtree is the beast on its own (don't like it personally but anyway)
You can try following snippet of code:
func! MyOpen() abort
let selected = g:NERDTreeFileNode.GetSelected()
if selected ...
1
vote
Is there a way to resize a split such that it exactly fits its content (plus/minus N lines of buffer-space)?
Manual approach
You can use 2<c-w>0 to resize current window to fit buffer, with 2 extra lines.
It's fully commented, read comment as explanation.
" Resize window to fit buffer + <count>...
1
vote
Accepted
Set option on window without going to the window and come back
The function setwinvar can change options using the & syntax:
call setwinvar(1, "&list", 0)
You can execute any code in the context of another window using win_execute (vim only):
call ...
1
vote
how to remotely focus Vim through the clientserver
I don't believe this is possible, other than by the methods you have already suggested.
I don't think Vim knows whether or not the terminal it is in has focus, and it definitely has no method of ...
1
vote
Shell running inside vim windows
For older Vim versions, there is Conque Shell, a no-longer-supported plugin which nevertheless has served me well in the past, and for now, continues to do so. It's still provided by e.g. vim-addons, ...
1
vote
Quit a window by its win_getid() identifier?
Recent vim includes win_execute() which works across tabpages.
call win_execute(og, 'close')
Beware of changes fired by autocmds from the vimhelp:
The window will temporarily be made the current ...
1
vote
How do I prevent a gVim server window stealing focus when receiving a remote command?
A solution to this problem is mentioned in Vim's documentation (:h --remote). The following command should open filename to line_number:
gvim --servername DEBUG --remote-send "<C-\><C-N&...
1
vote
If I split the screen and open a Netrw dir listing in one window, Vim won't let me focus that window
Starting vim using
vim -u NONE
won't work because you need a vimrc file with
set nocp
filetype plugin on
The two settings are needed because "netrw" is actually a plugin distributed with vim by ...
1
vote
How do I get the actual height and width of Vim?
104 columns / 51 lines = 2.04
Your calculation is skewed because the aspect ratio of each cell is vertical.
For example on Terminal.app, with 23pt font and default character spacing, each terminal ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
window-management × 35vim-windows × 14
gvim × 7
buffers × 6
split × 4
vimscript × 3
vimrc × 2
key-bindings × 2
neovim × 2
microsoft-windows × 2
netrw × 2
tabbed-user-interface × 2
terminal × 1
functions × 1
filetype × 1
filetype-tex × 1
register × 1
quickfix × 1
terminal-buffer × 1
plugin-nerdtree × 1
bash × 1
macos × 1
shell × 1
startup × 1
tmux × 1