Skip to content

Instantly share code, notes, and snippets.

@8ctopotamus
Last active June 20, 2026 13:41
Show Gist options
  • Select an option

  • Save 8ctopotamus/b519008bff09f8fa8301dd04310acdef to your computer and use it in GitHub Desktop.

Select an option

Save 8ctopotamus/b519008bff09f8fa8301dd04310acdef to your computer and use it in GitHub Desktop.
vim cheetsheet - no plugins (WIP)
  1. Exploring Project Structure Open a directory in Vim
vim
vim .

Navigate in netrw Key Action

  • j / k Move down/up
  • l Open directory or file
  • h Go to parent directory
  • i Change listing style (thin, long, wide, etc.)
  • + Create a new directory
  • d Create a new file
  • D Delete a file/directory
  • R Rename a file/directory
  • Press Enter on a file to open it in the current window.
  • Use % to create a new file.
  1. Managing Windows and Panes Split windows Command Action :split or :sp Split window horizontally :vsplit or :vsp Split window vertically :close or :q Close the current window :only Keep only the current window, close others Navigate between windows Key Action Ctrl + w then h / j / k / l Move to left/down/up/right window Ctrl + w then w Cycle through windows Ctrl + w then = Equalize window sizes Ctrl + w then + / - Increase/decrease window height Ctrl + w then > / < Increase/decrease window width Move windows

vim :resize +5 " Increase window height by 5 lines :resize -5 " Decrease window height by 5 lines :vertical resize +5 " Increase window width by 5 columns

  1. Using Tabs Tab commands Command Action :tabnew or :tabnew filename Open a new tab :tabclose Close the current tab :tabonly Close all other tabs :tabs List all tabs :tabn / :tabp Go to next/previous tab gt / gT Go to next/previous tab (normal mode) Open a file in a new tab

vim :tabedit filename

  1. Searching the Codebase Search in current file Key Action /pattern Search forward for pattern ?pattern Search backward for pattern n / N Go to next/previous match :%s/old/new/g Replace all old with new in file Search across multiple files

Use :grep (requires grep installed on your system):

vim :grep "pattern" *

Searches recursively in all files in the current directory.

Navigate grep results Key Action :cn Go to next match :cp Go to previous match :copen Open the quickfix list :cclose Close the quickfix list Search and replace across files

vim :grep "old_pattern" * :copen :%s//new_pattern/g :cdo s/old_pattern/new_pattern/g | update

Replaces old_pattern with new_pattern in all files with matches.
  1. Buffers (Working with Multiple Files) Buffer commands Command Action :ls List all open buffers :bnext / :bprev Go to next/previous buffer :bdelete Close the current buffer :buffer filename Open a specific buffer :bufdo Run a command on all buffers Switch between buffers

vim :b <partial_name> " Tab-complete to switch to a buffer

  1. File Navigation Shortcuts Key Action :e . Open netrw in current window :Ex Open netrw in current window (alternative) :Sex Open netrw in a horizontal split :Vex Open netrw in a vertical split :pwd Print current directory :cd path Change directory
  2. Macros for Repetitive Tasks Record a macro

vim qq " Start recording macro in register q ... " Perform actions q " Stop recording

Run a macro

vim @q " Run macro in register q 10@q " Run macro 10 times

  1. Miscellaneous Tips Save and quit all windows

vim :wall " Save all windows :qall " Quit all windows

Undo/Redo Key Action u Undo Ctrl + r Redo Copy/Paste Between Windows

Use "+y to yank (copy) to system clipboard.
Use "+p to paste from system clipboard.

Example Workflow

Open project:

vim
vim .

Split window vertically and open a file:

vim
:vsplit filename

Search for a pattern:

vim
:grep "function_name" *
:copen

Navigate grep results:

vim
:cn

Replace in all files:

vim
:cdo s/old/new/g | update

Use tabs for different files:

vim
:tabedit filename

  1. Opening a Terminal in Vim Basic Terminal Command

vim :terminal

Opens a terminal buffer in the current window.

Terminal Key Modes Mode Description Terminal-Normal Mode Press Ctrl + \ then Ctrl + n to exit terminal mode and enter normal mode. Terminal-Job Mode Press i or a to enter terminal mode and interact with the shell. Exit Terminal Type exit or Ctrl + d in the terminal buffer. 2. Terminal in a Split Window Horizontal Split

vim :split | terminal

or

vim :ter

Opens a terminal in a horizontal split.

Vertical Split

vim :vsplit | terminal

or

vim :vert ter

Opens a terminal in a vertical split.

Navigate Between Terminal and Code

Press Ctrl + \ then Ctrl + n to exit terminal mode and enter normal mode.
Press i to re-enter terminal mode and interact with the shell.
  1. Terminal in a Tab Open Terminal in a New Tab

vim :tabedit | terminal

or

vim :tab ter

Opens a terminal in a new tab.

Switch Between Tabs

Use gt (next tab) or gT (previous tab).
Use :tabn or :tabp to navigate tabs.
  1. Managing Multiple Terminals Open Multiple Terminals in Splits

    Open a terminal in a horizontal split:

    vim :split | terminal

    Open another terminal in a vertical split:

    vim :vsplit | terminal

    Navigate between them using Ctrl + w + h/j/k/l.

Open Multiple Terminals in Tabs

Open a terminal in a new tab:

vim
:tab ter

Repeat for additional terminals.
  1. Useful Terminal Commands in Vim Command Action :term ls Open a terminal and run ls immediately. :vertical terminal Open a terminal in a vertical split. :resize +5 Increase terminal window height by 5 lines. :vertical resize +5 Increase terminal window width by 5 columns. :q Close the terminal buffer (exit terminal first).

  2. Example Workflow

    Open project:

    vim vim .

    Split window vertically and open a terminal:

    vim :vsplit | terminal

    Run a command in the terminal:

    vim ls

    Split window horizontally and open a file:

    vim :split filename

    Navigate between windows: Ctrl + w + h/j/k/l Open a terminal in a new tab:

    vim :tab ter

    Switch between tabs: gt or gT

Scroll in VIM Terminal If you press Ctrl + w, followed by Shift + n, it pauses the terminal, and you can navigate it like any buffer. Pressing i takes you back into the terminal as you were before.

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