Menu

Monday, July 4, 2011

Vi Editor Commands


  • 1. What are the different editors in Linux to edit files?
    • 1. ed
    • 2. vi
    • 3. vim
    • 4. pico
  • 2. How to open a file in vi editor?
    • Syntax
    • # vi file-name
    • Example:
    • # vi names.txt
  • 3. How to quit a file?
    • Example:
    • Vi names.txt – Open a file in vi editor.
    • :q! – If you are in insert mode press escape before you type :q! to quit the editor without saving.
    • :wq – Quit vi editor with saving.
  • 4. Save commands in vi editor
    • q Quit
    • :q! Quit without saving
    • :qa Quit all fiels opened
    • :w Save changes
    • :wq Save and quit
    • zz Save and quit