This document provides a summary of basic commands for navigating, editing, searching, and saving text in command mode of the vi text editor. Some key navigation commands include using hjkl to move the cursor, 0 and $ to go to the start or end of a line, and G and gg to go to the end or start of the file. Common editing commands are i for insert mode, dd to delete a line, and p to paste copied or deleted text. Search and replace can be done with / and ? along with n and N to navigate between matches, and :s/old/new/g to replace text. Saving and quitting uses :w to write changes and :q to quit.
This document provides a summary of basic commands for navigating, editing, searching, and saving text in command mode of the vi text editor. Some key navigation commands include using hjkl to move the cursor, 0 and $ to go to the start or end of a line, and G and gg to go to the end or start of the file. Common editing commands are i for insert mode, dd to delete a line, and p to paste copied or deleted text. Search and replace can be done with / and ? along with n and N to navigate between matches, and :s/old/new/g to replace text. Saving and quitting uses :w to write changes and :q to quit.
This document provides a summary of basic commands for navigating, editing, searching, and saving text in command mode of the vi text editor. Some key navigation commands include using hjkl to move the cursor, 0 and $ to go to the start or end of a line, and G and gg to go to the end or start of the file. Common editing commands are i for insert mode, dd to delete a line, and p to paste copied or deleted text. Search and replace can be done with / and ? along with n and N to navigate between matches, and :s/old/new/g to replace text. Saving and quitting uses :w to write changes and :q to quit.
j: Move cursor down k: Move cursor up l: Move cursor right 0 (zero): Move to the beginning of the line $: Move to the end of the line G: Move to the end of the file gg: Move to the beginning of the file :<line number>: Move to a specific line number (e.g., :15) Editing:
i: Enter insert mode before the cursor
I: Enter insert mode at the beginning of the line a: Enter insert mode after the cursor A: Enter insert mode at the end of the line o: Open a new line below the current line O: Open a new line above the current line x: Delete the character under the cursor dd: Delete the current line yy: Copy the current line p: Paste the copied or deleted text after the cursor P: Paste the copied or deleted text before the cursor Undo/Redo:
u: Undo the last change
Ctrl + r: Redo the undone change Search and Replace:
/: Search forward (e.g., /pattern)
?: Search backward (e.g., ?pattern) n: Move to the next occurrence of the search pattern N: Move to the previous occurrence of the search pattern :s/old/new/g: Replace all occurrences of 'old' with 'new' in the current line :%s/old/new/g: Replace all occurrences of 'old' with 'new' in the entire file Saving and Quitting:
:w: Save changes
:q: Quit (if no changes) :wq or ZZ: Save and quit :q!: Quit without saving changes Insert Mode: In insert mode, you can type and edit text as you would in any other text editor. Exiting Insert Mode: Press Esc to exit insert mode and return to command mode. Remember that vi can have a steep learning curve, but it's a powerful editor once you become familiar with its commands.