Saturday, August 2, 2014

How to use vi text editor on Lubuntu

When it comes to console based text editor, vi is the best tool you can get, learning vi is very important, because you could survive on any unix system once you know how to use it.

The vi text editor is available by default on lubuntu system, you don't need to install, but there is a better version of vi called vim (vi improved). You can install vim if you want.

First of all vi is pronounced vee-eye, in general vi works in two different modes, the command mode and insert mode.

Command mode is where you run vi command, the vi command is usually start with : (colon sign), for example if you want to exit vi without saving, you type this command below.

:q!

There are so many commands that you can use on vi, here's some of them:

Command Function
:q exit vi
:q! exit vi without saving
:wq save and then exit vi
:w save
:help shows help for vi
dd delete current line
:10 go to spesific line, this case line 10
:= shows total lines
:.= returns line number of current line at bottom of screen
/text searching the word "text" on current documment, forward search
?text searching the word "text" on current documment, backward search

That's the command mode, the other is the insert mode, insert mode is where you edit the text file, where you type stuff you want to type.

By default when you open vi, you will be on command mode, to switch to insert mode, simply press i button on your keyboard.

From insert mode, if you want to switch back to command mode, simply press ESC (escape) button on your keyboard.

So you need to understand what mode are you in right now, the best way to do this is to try out for yourself.

This might be confusing for beginners, but once you get used to it, you will be happy editing text with vi or vim all day.


~ hope this help ~

No comments:

Post a Comment