top of page
Writer's pictureRuud Wijnands

My Vim Basics Cheat Sheet


neovim

Learning Vim is beneficial if you often use Unix or Linux systems. The following cheat sheet will help you get started with the basic commands you'll likely use most frequently.


Here is my vim cheat sheet. You can also find a download link at the bottom of this page.

Description

Command

Moving around


Move the cursor two words left

2w

Move the cursor to the end of the 3rd word

3e

Move the cursor the the start of the line

0

Move to the start of the next word

w

Move to the end of the next word

e or E

Move a word backward

b or B

Deleting


d <number> <motion>


Delete until the end of the line

d$

Delete until the start of the next word

dw

Delete until the end of the current word

de

Delete the next two words

d2w

Delete the current line

dd

Delete the next two lines

2dd

Delete character at the cursor

x

Undo/Redo


Undo last change

u

Undo the whole line

U

Redo

Crtl-r

Put (paste)

p

Replace


Replace the character at the cursor

r

Replace more than one character

R

Changing


c <number> <motion>


Change until the end of the word

ce

Change until the end of the line

c$

Change the next two words

c2w

Cursor location and file status


Show location in file and status

Ctrl-g

Move to the bottom of the file

G

Move to the start of the file

gg

Move to line number

<number>G

Search


Search the word at the cursor

*

Search forwards + phrase

/<phrase>

Search backward + phrase

?<phrase>

Search the next word (forward)

n

Search the previous word (backward)

N

Go back to where you came from backwards

Crtl-o

Go back to where you came from forwards

Crtl-i

Disable search highlight temporarily (cmd-mode)

:noh

Matching parentheses search


Type % to find the matching ) } ]

%} or %] or %)

Substitute (Search and replace)

:s

Substitute 'old' with 'new'

:s/old/new

Substitute 'thee' with 'the' globally in the line

:s/old/new/g

Substitute between line numbers # and #

#,#s/old/new/g

Substitute every occurrence in the whole file

:%s/old/new/g

Substitute every occurrence in the whole file and prompt to confirm

:%s/old/new/gc

Executing external commands


Write file (default has no filename for nvim)

:w

Write file <FILE>

:w FILE

Writing a selection to a file (start visual selection v and enter : until you see '<,'> at the bottom of the screen

'<,'>w FILE

Opening and reading a file `<FILE>`

:r FILE

Merging a file at the current position in the current file

:r FILE

Open Command


Move the cursor to the next line and switch

(insert mode)

o

Move the cursor to the previous line and switch (insert mode)

O

Append from the cursor (insert mode)

a

Append at the end of the line (insert mode)

A

Copy & Paste


Use visual select v and highlight what you want to copy and press y for yank to copy

y

Copy the next word

yw

Paste after the cursor

p

Paste before the cursor

P

Set options


Enable ignore case (for search)

:set ic

Disable ignore case

:set noic

Enable highlight search

:set hlsearch

Disable highlight search

:set nohlsearch

Enable show partial matches search

:set inc

Disable show partial matches search

:set noinc

Getting help


Open the help

F1 or :help

Find help for <topic>

:help <topic>

Move to the next window pane

Ctrl-w

Command completion (command mode)

Ctrl-d (e.g. :w Ctrl-d shows all commands starting with w)

Quitting


Quit vim

:q

Quit and ignore changes made to the file

:q!

Quit and write changes made to the file

:qw



47 views0 comments

Recent Posts

See All

Comments


bottom of page