Limited Time Offer!
For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!
Enroll Now
Here’s a comprehensive list of shortcuts for the Vi editor in Linux.
🔹 Basic Vi Commands
Command Description vi filenameOpen a file in Vi editor iInsert mode (start editing) EscExit insert mode :wSave the file :qQuit Vi :q!Quit without saving :wq or ZZSave and quit :xSave and quit (same as :wq) :w filenameSave as a new file
🔹 Navigation Commands
Command Description hMove left lMove right jMove down kMove up 0Move to the beginning of the line ^Move to the first non-blank character of the line $Move to the end of the line wMove to the next word eMove to the end of the current/next word bMove to the beginning of the previous word ggMove to the beginning of the file GMove to the end of the file ngMove to line number n (e.g., 5G moves to line 5) Ctrl + dScroll down half a screen Ctrl + uScroll up half a screen Ctrl + fScroll forward one full screen Ctrl + bScroll backward one full screen
🔹 Editing and Inserting
Command Description iInsert at the cursor position IInsert at the beginning of the line aAppend after the cursor AAppend at the end of the line oOpen a new line below the cursor OOpen a new line above the cursor rReplace a single character RReplace multiple characters (overwrite mode) xDelete character under the cursor XDelete character before the cursor ddDelete (cut) the entire line yyCopy (yank) the entire line pPaste after the cursor PPaste before the cursor uUndo the last action Ctrl + rRedo the last undone action JJoin the current line with the next line
🔹 Deleting (Cut) Commands
Command Description dwDelete a word deDelete to the end of the current word d$Delete from cursor to end of line DDelete from cursor to end of line (same as d$) d0Delete from cursor to beginning of line ddDelete the current line dGDelete from current line to end of file dggDelete from current line to beginning of file
🔹 Copy & Paste (Yank)
Command Description yy or YCopy the current line ywCopy a word y$Copy to the end of the line y0Copy to the beginning of the line pPaste after the cursor PPaste before the cursor
🔹 Search & Replace
Command Description /textSearch forward for “text” ?textSearch backward for “text” nRepeat last search in the same direction NRepeat last search in the opposite direction :%s/old/new/gReplace all occurrences of “old” with “new” in the file :s/old/new/gReplace all occurrences of “old” with “new” in the current line :s/old/new/gcReplace with confirmation
🔹 Working with Multiple Files
Command Description :e filenameOpen another file in Vi :bnGo to the next buffer (file) :bpGo to the previous buffer (file) :bdClose the current buffer :sp filenameOpen file in a new horizontal split :vs filenameOpen file in a new vertical split Ctrl + w + wSwitch between split windows
🔹 Marks & Jumps
Command Description maMark the current position as “a” 'aJump to the marked position “a” Jump back to the last cursor position Ctrl + oJump to the previous location Ctrl + iJump forward to the next location
🔹 Visual Mode (Selection)
Command Description vStart visual mode (character selection) VStart line selection mode Ctrl + vStart block selection mode (column selection) yCopy the selected text dDelete the selected text >Indent the selected text <Un-indent the selected text
🔹 Advanced Commands
Command Description :set numberShow line numbers :set nonumberHide line numbers :set ignorecaseIgnore case in searches :set noignorecaseCase-sensitive searches :set hlsearchHighlight search results :set nohlsearchRemove search highlights :set wrapEnable text wrapping :set nowrapDisable text wrapping
🔹 Exiting Vi
Command Description :qQuit Vi (only if no changes were made) :q!Quit without saving changes :wq or ZZSave and quit :xSave and quit (same as :wq)
🎯 Bonus: Vi Cheat Sheet
Insert Mode: i, I, a, A, o, O
Navigation: h, l, j, k, w, b, 0, $
Editing: x, dd, yy, p, P, u, Ctrl + r
Search: /text, ?text, n, N
Replace: :%s/old/new/g
Exit: :q, :q!, :wq, ZZ
🚀 Practice These Commands
To master Vi, start practicing:
Open a file with vi filename
Navigate with h, l, j, k
Edit with i, a, o
Save with :w, quit with :q
Experiment with cut (d), copy (y), paste (p)
Search (/text), Replace (:%s/old/new/g)
Let me know if you need any specific Vi commands! 🚀🔥
Post Views: 1,919