Vi

From Mandrivausers Wiki

Jump to: navigation, search

Vi is a very common command-line text editor for Linux systems, with a reputation for being difficult for beginners to use. Often a gui-based editor such as Kate would be used for complicated editing jobs, but vi can be quickly used from the console for small editing tasks.

This article needs a screenshot to illustrate it. As soon as file uploads are enabled, please add a screenshot here.

[edit] Modes

Vi has two main modes, and what happens when you press a key depends on which mode it is currently in. One mode is command mode where vi interprets keys as commands (for example, delete, or go forward one word). The other mode is insert mode, where the keystrokes get written into the file.

Switching between modes is therefore vital, use i to enter insert mode, and the Esc key to go back to command mode.

[edit] Very basic commands

To start vi to edit the named file (if it doesn't exist vi will create it)

vi myfile.txt

To enter insert mode so we can add some text

i

To add some text at the cursor

This is my text

To go back to command mode

Esc

To save changes and exit vi

:wq

Or, to exit vi without saving changes

:q!

[edit] External links

Personal tools