Search This Blog

Complete vi editior commands

The Vi editor is a powerful and widely used text editor in Unix-like operating systems. Here is a list of some common Vi commands:

Command Modes:

  1. Normal Mode:

    • i: Switch to insert mode before the cursor.
    • I: Switch to insert mode at the beginning of the current line.
    • a: Switch to insert mode after the cursor.
    • A: Switch to insert mode at the end of the current line.
    • o: Open a new line below the current line and switch to insert mode.
    • O: Open a new line above the current line and switch to insert mode.
    • x: Delete the character under the cursor.
    • dd: Delete the entire line.
    • yy: Yank (copy) the entire line.
    • p: Paste the yanked text after the cursor.
    • P: Paste the yanked text before the cursor.
    • u: Undo the last change.
    • Ctrl + r: Redo the last undone change.
    • :w: Save changes (write).
    • :q: Quit.
    • :q!: Quit without saving changes.
    • :wq or ZZ: Save changes and quit.
  2. Insert Mode:

    • Press Esc to switch back to normal mode.

Navigation:

  1. Basic Movement:

    • h: Move left.
    • j: Move down.
    • k: Move up.
    • l: Move right.
  2. Word Movement:

    • 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 current word.
  3. Line Movement:

    • 0: Move to the beginning of the line.
    • $: Move to the end of the line.
    • ^: Move to the first non-blank character of the line.
    • G: Move to the end of the file.
    • gg: Move to the beginning of the file.
    • :n: Move to the n-th line.
  4. Search:

    • /pattern: Search forward for a pattern.
    • ?pattern: Search backward for a pattern.
    • n: Move to the next occurrence of the search pattern.
    • N: Move to the previous occurrence of the search pattern.
  5. Other Movement:

    • %: Move to the matching parenthesis or bracket.

Visual Mode:

  1. Enter Visual Mode:

    • v: Start visual mode character-wise.
    • V: Start visual mode line-wise.
    • Ctrl + v: Start visual mode block-wise.
  2. Text Selection:

    • Use movement commands to select text.
    • y: Yank (copy) the selected text.
    • d: Delete the selected text.

These are just some of the basic Vi commands. Vi has a rich set of features and commands, so feel free to explore more as you become comfortable with the basics. Additionally, Vim, an improved version of Vi, provides even more functionalities.

No comments:

Post a Comment

Featured Post

Oracle Architecture

  An Oracle Database consists of at least one database instance and one database. The database instance handles memory and...