Skip to content

Instantly share code, notes, and snippets.

@somahargitai
Last active April 14, 2023 16:31
Show Gist options
  • Save somahargitai/743f37be39f64e6abb594917012ab4ec to your computer and use it in GitHub Desktop.
Save somahargitai/743f37be39f64e6abb594917012ab4ec to your computer and use it in GitHub Desktop.
Vim Cheatsheet

cheatsheet list

Vim Cheat Sheet

Freecodecamp article
Neovim install
Devhints Vim Cheatsheet

Basics

command description
: go to command mode from normal mode
Esc go back to normal mode
:q close file
:qa close all file
:q! exit and ignore changes
:wq exit and save changes
:!ls run terminal command ls without leaving vim

Insert mode

command description
i insert mode
a insert mode - insert after current character
o, O insert mode - insert into new line below
I insert mode - insert into beginning of this line
A insert mode - insert into end of this line

Move commands in normal mode

Move inside the code:

  • cursor buttons
  • or h, j, k, l

Move inside the code, multiple steps:

  • 3h, 4j, 5k, 2l, etc.
  • or 3 ⬇️ etc.
command description
w beginning of next word
b previous beginning of word
e end of word
W beginning of next word after a whitespace
B beginning of previous word before a whitespace
E end of word before a whitespace
0 the beginning of the line
$ the end of the line

Settings

by command:

command description
:set number add line numbers to the editor
:set relativenumber add line numbers relative to the actual line
:set mouse=a enable mouse clicks

by file:

vi ~/.vimrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment