Vim splits and tabs

Updated: 28 October 2024

Move active window to a new tab
:tab split

Move to next tab
gt

Move to previous tab
gT

Start vim with files in horizontal splits

vim -o fileA fileB

Start vim with files in vertical splits

vim -O file1 file2

Vim scrolling

Updated: 02 January 2023

Goto halfway through a long file (no colon required)

50%

Move current line to middle of screen

zz

Vim statusline

Updated: 10 December 2022

Restore default statusline

set statusline=

Show value of character under cursor in decimal and hex

set statusline=%b\ 0x%B

Vim directories and path

Updated: 10 September 2022

Current Directory is where vim was started, :pwd and :cd apply. “Directory of current file” could be different to Current Directory.

When setting the path . and ,, refer to the current directory and directory of current file.

Vim quickfix

Updated: 30 June 2023

The quickfix list is global.
The location list is local to the current window.

Open a window to show the current list.
:cope[n]

Go to an older list
:col[der]

Go to a newer list
:cnew[er]

Go to the next error in the window
:cn

Go to the previous error in the window
:cp

netrw

Updated: 12 May 2023

Make word below cursor the top of tree listing
gn

Toggle dot files
gh

Rename a file
R

Delete a file
D

Create a new file
%

Open file in new horizontal split
o

Open file in new vertical split
v

Open file in new tab
t

Create a new directory
d

Refresh directory listing
Ctrl+l

Reverse sort order
r

Preview window

open
p

close
:pc

Vim folding

Updated: 18 November 2023

Toggle fold
za

Close all
zM

Open all
zR

Eliminate all folds in window (foldmethod “manual” or “marker”)
zE

For html

:set foldmethod=indent

Disable folding

:set nofoldenable

Foldtext

Remove foldtext

:set foldtext=''

Default foldtext

:set foldtext=foldtext()