← Back to Blog

Vi Commands and Text Blaze

Vi Commands and Text Blaze Certainly!

Vi Commands and Text Blaze

vi commands and 1

Certainly! Below is a list of basic vi commands categorized by their functionality:

Basic Navigation

  • h: Move cursor left
  • j: Move cursor down
  • k: Move cursor up
  • l: Move cursor right
  • 0 (zero): Move to the beginning of the line
  • ^: Move to the first non-blank character of the line
  • $: Move to the end of the line
  • w: Move to the beginning of the next word
  • b: Move to the beginning of the previous word
  • e: Move to the end of the next word
  • G: Move to the end of the file
  • gg: Move to the beginning of the file
  • H: Move to the top of the screen
  • M: Move to the middle of the screen
  • L: Move to the bottom of the screen

Inserting Text

  • i: Insert before the cursor
  • I: Insert at the beginning of the line
  • a: Append after the cursor
  • A: Append at the end of the line
  • o: Open a new line below the current line
  • O: Open a new line above the current line

Deleting Text

  • x: Delete the character under the cursor
  • X: Delete the character before the cursor
  • dd: Delete the current line
  • dw: Delete from the cursor to the end of the word
  • d$: Delete from the cursor to the end of the line
  • d^: Delete from the cursor to the beginning of the line
  • D: Delete from the cursor to the end of the line (same as d$)

Changing Text

  • cw: Change from the cursor to the end of the word
  • cc: Change the entire line
  • C: Change from the cursor to the end of the line
  • r: Replace a single character
  • R: Enter replace mode

Copying and Pasting

  • yy: Yank (copy) the current line
  • yw: Yank (copy) from the cursor to the end of the word
  • y$: Yank (copy) from the cursor to the end of the line
  • p: Paste after the cursor
  • P: Paste before the cursor

Undo and Redo

  • u: Undo the last change
  • U: Undo all changes on the current line
  • Ctrl + r: Redo the last undone change

Search and Replace

  • /pattern: Search for pattern
  • ?pattern: Search backward for pattern
  • n: Repeat the last search
  • N: Repeat the last search in the opposite direction
  • :%s/old/new/g: Replace all occurrences of old with new in the entire file

Exiting

  • :w: Write (save) the file
  • :q: Quit vi
  • :wq: Write (save) and quit
  • :q!: Quit without saving changes
  • :x: Write (save) and quit (same as :wq)

Visual Mode

  • v: Start visual mode (character-wise)
  • V: Start visual mode (line-wise)
  • Ctrl + v: Start visual block mode

Advanced Editing

  • .: Repeat the last change
  • J: Join the current line with the next line
  • >: Indent line right
  • <: Indent line left

Miscellaneous

  • :set number: Show line numbers
  • :set nonumber: Hide line numbers
  • :help: Open the help file

These commands cover a wide range of basic and intermediate functionality in vi. If you need more advanced or specific commands, feel free to ask!


Imported from rifaterdemsahin.com · 2025