This section introduces some of the text editors you may need to make changes to files.
Full Screen Editors
If you explore the KDE=Applications: Debian Menu > Apps > Editors offerings you will find a number of text editors to choose
from, and the choice is yours. Those listed will probably be:
- AbiWord Word Processor
- Gedit
- KEdit
- Kword
- KWrite
- Kate
- Nano
- Quanta Plus
- Xedit
- gvim
In most of the examples shown in these pages we have used Nano, because it is easy to use and does most of the things
that the average user needs to do. gvim is the graphical version of vi (also available but not shown in the menu),
which is probably the most powerful editor available designed for programmers and Linux gurus but is not user-friendly.
More About Vi
There will be times when someone will explain how to do something using 'vi' because it has powerful commands not available in other
text editors, especially when executing the text editor from a script, so the following is a brief intro to 'vi'. While it would be
great to give you a quick tutorial on how to use vi, it isn't that easy, and there must be dozens of documents that have been
written on how to tame it. If you type man vi followed by the Enter key you will find about 1500 lines introducing some of the
parameters available to configure vi, but very little on how to use it apart from references to other documents that you can read.
The first thing to understand is that Vi is a line editor so it works in lines, and every line typically represents one command
set. This doesn't mean that every command fits on one line on the screen - depending on the contents it may wrap across several lines
on the display, but to vi it is a single line that ends with a carriage return.
The most used key in vi must be the Esc key, as it can be used to make or break a command sequence entered from the keyboard,
and essentially switch you between command mode and line mode, and understanding the difference is very important.
Let's look at a very short example on using vi where the characters typed are shown in blue and other keys pressed are in black:
|
vi example[Enter]
|
This says to either edit a file called "example", or if no files by that name exists in the current directory, then create one.
|
|
[Esc]i
|
The Esc key readies vi to accept a command, in this case "i" for insert, although nothing will appear to happen.
|
this is a line of text[CR]
more lines of text[CR]
_
|
We can now type a line of text and when we have finished we press the Enter key - this will generate a carriage return [CR] and
take us to the next line ready for more input. We can continue to type more lines of text using the Enter key at the end of each
line until we are finished.
|
|
[Esc]
|
pressing the Esc key again resets the insert command.
|
more_lines of text[CR]
|
using the cursor keys we can move the cursor up one line and right four chars, to the "l" of lines, just like we
would in any text editor.
|
[Esc]xxxxxxxxx
more text[CR]
|
Each "x" deletes one character, so this sequence deletes the characters "lines of" leaving us with "more
text".
|
|
[Esc]A
|
The Esc key followed by "A" (upper-case A) tells vi to add at end of line, and the cursor will jump there ready for more input.
|
more text lines[CR]
yet another line_[CR]
|
Using this technique we can add to the end of an existing line without having to cursor there, or as in this example we can add
a new line as well.
|
|
[Esc]:wq
|
Finally we can save our changes by invoking command mode using Esc followed by :, then "w" to write the file, and
"q" to quit. And just in case you need to know how to quit without saving use Esc:q! (obvious isn't it?)
|
Ok, this example might be rather simple and somewhat contrived but it hopefully gives you some idea of just how quirky 'vi' is.
The next aspect we need to understand are the Commands.