Vim/Splits
Vim/Neovim offers a powerful split window feature.
:sp[lit]
splits horizontally and :vs[plit]
splits vertically.
You can add the filename and it will open that file for the new split.
If not, it will show a ‘view’ of the current buffer, which is often useful.
You can also do :sp|:term[inal]
or :vs|:term
to open a terminal window, which behaves like a normal split window.
These windows can be quickly resized & moved.
Basic key bindings and useful vimrc settings
Check out DistroTube: Managing your splits in Vim for more information.
CTRL-w
+_
or|
: maximize the current split.CTRL-w =
: equalize the splits.:only
: close all other windows.CTRL-w CTRL-r
: rotate windows.CTRL-w r
: swap.
You can do the following to remap CTRL+hjkl
for moving around splits.
noremap <C-h> <C-w>h
The resizing can also become easier with the following setup.
noremap <silent> <C-Left> :vertical resize -3<CR>
noremap <silent> <C-Right> :vertical resize +3<CR>
noremap <silent> <C-Up> :resize +3<CR>
noremap <silent> <C-Down> :resize -3<CR>
Opening up a terminal can be simplified by having a setting like this:
map <leader>vt :vnew term://zsh<CR>