Linux - Vi

Introduction

To edit files on the command line, you can use an editor such as vi. To open the file, run

vi /path/to/file

The contents of the file must appear.

The file is created if it does not exist yet.

Articles Related

The most important commands

The most important commands in vi are these ones:

Command Description Mode
i enter in the Insert mode. It enable you to type in your text. Normal Mode
ESC leave the Insert mode press Insert Mode
x delete the character that is currently under the cursor Normal Mode
:x save the file Normal Mode
:w write the file Normal Mode
:q leave the file Normal Mode
:q! leave the file without saving the changes Normal Mode

Please note that you can use your keyboard's arrow keys to navigate the cursor through the text.

How to edit a file with Vi?

Then when you want to edit a file, the logical sequence is:

  • to tape i to enter in Insert Mode
  • to made the modifications
  • to press the ESC button to leave the insert mode and to enter in a normal mode
  • and save the file by entering the command :x
  • Bookmark "Linux - Vi" at del.icio.us
  • Bookmark "Linux - Vi" at Digg
  • Bookmark "Linux - Vi" at Ask
  • Bookmark "Linux - Vi" at Google
  • Bookmark "Linux - Vi" at StumbleUpon
  • Bookmark "Linux - Vi" at Technorati
  • Bookmark "Linux - Vi" at Live Bookmarks
  • Bookmark "Linux - Vi" at Yahoo! Myweb
  • Bookmark "Linux - Vi" at Facebook
  • Bookmark "Linux - Vi" at Yahoo! Bookmarks
  • Bookmark "Linux - Vi" at Twitter
  • Bookmark "Linux - Vi" at myAOL
 
linux/vi.txt · Last modified: 2010/03/12 18:04 by gerardnico