Vim searching

Updated: 07 November 2023

:grep uses external grep command.

:vimgrep uses vim’s internal grep facility.

:lgrep Same as :grep except the location list for the current window is used instead of the quickfix list.

Word boundaries

/\<word\>

* search for word currently under cursor.
[I show lines with matching word under cursor.

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: 01 March 2025

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 supports per tab working directories.
Neovim supports per tab working directories.
LazyVim, with no modifications, does not support per tab working directories.

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