๐ Introduction
This post is primarily for my own use, containing Vim commands that I frequently use or am trying to learn and remember. It focuses on essential motions and navigation techniques to improve efficiency.
Note: This post changes and updates frequently.
๐ Basics
Basic commands to get started with Vim.
iโ Insert modeESCโ Exit insert mode:wโ Save file:qโ Quit:wqorZZโ Save and quit:q!โ Quit without saving
๐ Moving Around
Essential motions for navigating within a file efficiently.
hโ Leftjโ Downkโ Uplโ Right0โ Beginning of line^โ First non-blank character of line$โ End of linewโ Next wordbโ Previous wordeโ End of wordggโ Go to start of fileGโ Go to end of file5Gโ Go to line 5Ctrl-dโ Move down half a screenCtrl-uโ Move up half a screenCtrl-fโ Move forward one full screenCtrl-bโ Move backward one full screen
๐ Searching and Replacing
Commands to search within a file and replace text efficiently.
/patternโ Search forward?patternโ Search backwardnโ Repeat last search forwardNโ Repeat last search backward:%s/old/new/gโ Replace alloldwithnew:.,+3s/old/new/gโ Replace in current and next 3 lines
๐ Working with Files
File management commands to open, navigate, and switch between files efficiently.
:e filenameโ Open file:tabe filenameโ Open in a new tab:sp filenameโ Open in a horizontal split:vsp filenameโ Open in a vertical split:lsโ List open buffers:bnextor:bnโ Next buffer:bprevor:bpโ Previous buffer:bdโ Delete buffer
๐ Editing
Essential editing commands for modifying text quickly.
xโ Delete character under cursorddโ Delete (cut) current lineyyโ Copy current linepโ Pasteuโ UndoCtrl-rโ RedoVโ Visual line selectionvโ Visual character selectionyโ Yank (copy)dโ Delete (cut)cโ Change (delete and enter insert mode)
๐ฏ Marks and Jumps
Marks allow you to bookmark positions in your file and jump between them easily.
โ Jump back to last cursor position''โ Jump back to last line:marksโ Show marksmXโ Mark position withX'Xโ Jump to markX
โจ๏ธ Macros
Macros allow you to record and replay sequences of commands, helping with repetitive tasks.
qXโ Start recording macroXqโ Stop recording@Xโ Run macroX@@โ Run last macro
๐ Miscellaneous
Various useful commands for enhancing workflow.
:nohโ Remove search highlight:set numberโ Show line numbers:set relativenumberโ Show relative line numbers:set ignorecaseโ Case-insensitive search:set smartcaseโ Case-sensitive when uppercase is usedCtrl-gโ Show file info
๐ Tip: Mastering these commands will make you lightning-fast in Vim!
Let me know if you’d like any additions or modifications! ๐
