What's the deal with Deno? We talk with a major contributor to find out. Listen now.

Hot answers tagged

231

There are several window commands that allow you to do this: Ctrl+W +/-: increase/decrease height (ex. 20<C-w>+) Ctrl+W >/<: increase/decrease width (ex. 30<C-w><) Ctrl+W _: set height (ex. 50<C-w>_) Ctrl+W |: set width (ex. 50<C-w>|) Ctrl+W =: equalize width and height of all windows See also: :help CTRL-W


86

Yes, vim has the ability to split both horizontally using :split and vertically using :vsplit which both work just like :edit for opening a file, except they open it in a horizontal / vertical split respectively. Additionally, I would recommend to also read :h window-move-cursor for moving around different splits with ease.


65

You can use the option -o to open the files in horizontal splits or -O (letter "O") to open vertical splits. The following commands open a window for each file specified: vim -o *.cpp vim -O foo bar baz You can tell Vim the maximum number of windows to open by putting an integer after o or O options, the following example will open at most two ...


59

You can also use the resize commands: :resize [+-]N - resize a horizontal split, increasing or decreasing height by N characters. :vertical resize [+-]N - resize a vertical split, increasing or decreasing height by N characters. :resize N - resize a horizontal split, setting height to N characters. :vertical resize N - resize a vertical split, setting width ...


59

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


49

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


43

This is one of the few reasons I like to use vim's mouse mode. If you use the GUI version, or your terminal supports sending drag events (such as xterm or rxvt-unicode) you can click on the split line and drag to resize the window exactly where you want, without a lot of guess work using the ctrl-w plus,minus,less,greater combinations. In terminal versions,...


37

You are wrong about tmux. Like every terminal-based program — including Vim — it only draws stuff inside cells. This means that Vim and tmux both use the same method to draw vertical borders: they just use a pipe-like character. Tmux uses │ (U+2502) by default while Vim uses | (U+007C). If you want the same separator in Vim, you can simply use the same ...


35

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


29

To go along with @janos's answer, you can set an autocmd to automatically press those keys when the window is resized (put this in your .vimrc without the leading colon if you want it to apply every time you open Vim): :autocmd VimResized * wincmd = Here are the docs for the VimResized autocmd.


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

You can use Ctrlw-x. From :he CTRL-W_x: CTRL-W x CTRL-W_x CTRL-W_CTRL-X CTRL-W CTRL-X Without count: Exchange current window with next one. If there is no next window, exchange with previous window. With count: Exchange current window with Nth window (first window ...


25

Yes, there are the :split (split into two windows, top half and bottom half) and :vsplit (left and right) commands. You can then use Ctrl-W direction to switch windows (where direction is one of the normal hjkl cursor movement keys, or the arrow keys). You can then :edit (etc.) a different file in each window. Full documentation is at :help windows.txt.


24

To scroll two windows together in vim, need to run :set scrollbind in each of them. As you noted, by default, this only binds vertical scrolling. In the docs for scrollbind, it mentions: The behavior of 'scrollbind' can be modified by the 'scrollopt' option. :help scrollopt reveals that you want to say :set scrollopt+=hor to enable horizontal scrolling. ...


20

You can use :enew. See :h :enew: 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 written. And you can use :enew! to discard unsaved changes in the current buffer.


19

Use the command :qall!, :qa! for short, or its safer alternative :qall that prevent to discard modified buffers. To save all buffers before quitting use the command :wqall. See :help window-exit for the full set of commands to quit multiple windows at once.


19

You can either split vim windows by opening multiple files using -o, -O, -o2 parameters. Or if you're already editing multiple files in one window, you can use :ba to split horizontally or :vert ba to split vertically. :[N]ba[ll] [N] :[N]sba[ll] [N] Rearrange the screen to open one window for each buffer in the buffer list. :vert[ical] {cmd} ...


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


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

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

Ctrlw= will resize the split panes to become equal. But I don't know how to make them equal automatically, triggered when the window is resized.


15

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


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


13

As you would switch any other window, <c-w>x or <c-w>r are two options. Having only two windows opended <c-w>k will switch them and leave the cursor in the window where it was before the switch (i.e. if before the switch the focused window is on the left, after the switch it will be on the left). <c-w>x will switch the windows and ...


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


12

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


11

What you're looking for is :Vexplore. From your question, it sounds like you started off knowing only about :Sexplore and understandably thought that that was the basic command for bringing up the vim file explorer (which is called netrw). However, the basic command is just :Explore, and :SExplore is actually just a variant of that. The basic :Explore ...


10

Another alternative to swapping windows or swapping the buffers, is to mark positions (using uppercase marks) in your files and open up those marks in the windows of your choosing. For example if I have two files, file_A and file_B: I would go the window with file_A and mark it: mA go to the window with file_B and mark it: mB Then fetch the mark of ...


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