span.fullpost {display:inline;}

Wednesday, October 1, 2008

VI AND EMACS

All configuration files in Linux are written in plain English, easy to read and to adapt. We use a text-editor to write or make changes to those files.
The two most popular, powerful and “difficult” editors that you will find in every distro are Vi and Emacs. They both have “syntax-highlighting” to make writing code easy.

NOTE: Vi and Emacs fans fight bitter religious wars over which is better.

Vi

There are hundreds of commands for Vi, we will only touch the absolute minimum.


CODE
$ vi tessst


Will open the file tessst in located in your /home, if the file does not exist it will create one.
Vi has 3 modes: a command mode, an insert mode and an ex mode.
When you start Vi it starts in command mode. So we first have to type an "i" to put it in insert mode. Now you can type “the quick brown fox etc.”
After inserting the text we go back to command mode <> and save the file with ZZ. Thats all we have to know for the beginning.: "i" for insert <> for command, ZZ for saving the file.

Some more commands for Vi: ( less important )
i = insert text before the cursor
a = insert text after the cursor
: = switch to ex mode
$ = go to last place on the line
^ = go to first place on the line
w = next word
b = previous word
G = last line of the file
20G = go to line no 20
y = copy ( y3w = copy 3 words ) ( y3j = copy 4 lines )
p = paste
d = cut
x = delete character under the cursor




Emacs

Emacs is made easy because these days it has a GUI in modern distro's, but we will use the keyboard because it has more speed.


CODE
$ emacs ssset


Will open or create the file ssset in your /home
OK type away: “ the quick brown etc”.
Now to save the file do: Ctrl+x, Ctrl+c, y
Well I said we were going to keep it simple !

Leave the tessst and ssset files in your /home, in the next section we can do some exercises with them.

0 comments:

Tutorialsland By - Templates4all | Free Blogger and web Templates
Free Website templatesFree Flash TemplatesFree joomla templatesSEO Web Design AgencyMusic Videos OnlineFree Wordpress Themes Templatesfreethemes4all.comFree Blog TemplatesLast NewsFree CMS TemplatesFree CSS TemplatesSoccer Videos OnlineFree Wordpress ThemesFree Web Templates