Here is a summary of the essential commands for Neovim (nvim) organized by mode for easy viewing.
I hope this helps those using Neovim.

Neovim Command Summary Illustration


1. Mode Switching

Shortcut Description
Esc or Ctrl + [ Switch to Normal Mode
i Enter Insert Mode at the current cursor position
I Enter Insert Mode at the beginning of the current line
a Enter Insert Mode after the cursor
A Enter Insert Mode at the end of the current line
o Add a new line below and enter Insert Mode
O Add a new line above and enter Insert Mode
v Enter Visual Mode
V Enter Line Visual Mode
: Enter Command Mode

2. File Management

Command Description
:w Save the file
:wq or :x Save and exit
:q Exit (if no changes)
:q! Force exit (ignore changes)
:e filename Open a file or create a new one
:ls List currently open buffers
:bn, :bp Move to the next or previous buffer
:edit Same as :e. If the specified file path doesn't exist, Nvim opens a new empty buffer with that name
:e [new_file_path] Create a new directory or file (add / at the end to create a directory)

3. Cursor Movement

Shortcut Description
h, j, k, l Move left (h), down (j), up (k), right (l)
w, b Move forward (w) and backward (b) by word
0, $ Move to the beginning (0) or end ($) of the current line
gg, G Move to the top (gg) or bottom (G) of the file
{n}G Move to the {n}th line (e.g., 10G moves to the 10th line)
Ctrl + d Scroll down half a page
Ctrl + u Scroll up half a page

4. Editing Commands

Shortcut Description
dd Delete the current line
dw Delete a word
x Delete the current character
yy Copy the current line
p, P Paste the copied/deleted content after (p) or before (P)
u Undo
Ctrl + r Redo
r{char} Replace the current character with {char}
:%s/find_word/replace_word/g Search and replace a word throughout the document

5. Search and Replace

Command Description
/search_term Search forward
?search_term Search backward
n Go to the next search result
N Go to the previous search result
:noh Remove search highlights

6. Window Management

Command Description
:split or :sp Split the window horizontally
:vsplit or :vsp Split the window vertically
Ctrl + w, hjkl Move between windows (up, down, left, right)
Ctrl + w, c Close the current window
Ctrl + w, = Equalize the size of all windows
Ctrl+w, > Increase the size of the selected window
Ctrl+w, < Decrease the size of the selected window

7. Tab Management

Command Description
:tabnew Open a new tab
gt, gT Move to the next tab (gt) or previous tab (gT)
:tabclose Close the current tab

8. nvim-tree Commands

Creation Command Input (Default Shortcut):

  • a (add): Creates a new file or directory. After pressing a, a prompt appears at the bottom where you can input file/directory name.
    • Input file.py and press Enter -> Creates file.py
    • Input new_dir/ and press Enter -> Creates new_dir
    • Input another_dir/another_file.txt and press Enter -> Simultaneously creates another_dir and another_file.txt within it
  • d (delete): Deletes the selected file/directory
  • r (rename): Renames the selected file/directory
  • x (cut), c (copy), p (paste): Cut/Copy/Paste files/directories

9. Using Nvim's Built-in Terminal (:terminal or :term)

Nvim has a built-in terminal emulator that allows you to directly execute Linux commands.

  1. Opening the Terminal: Input :terminal or :term in command mode and press Enter.

    • A new terminal buffer opens within the Nvim window.
    • Press i in normal mode to start terminal input.
  2. Exiting the Terminal:

    • Press Ctrl + \ and then Ctrl + n (to return to Normal Mode)
    • Or enter the exit command in the terminal
  3. Returning to File Editing Mode:

    • Use Ctrl + w w (to move to the next window) or Ctrl + w h/j/k/l (using arrow keys to navigate) to return to the file window you were editing.

Referencing this command cheat sheet will help you use Neovim more efficiently!