Editors.


One of the most useful tools that you will be using is a standard text editor. This is because almost all the files on a Linux system are editable "text" files. There are a great many editors available for Linux, the choice of which you prefer will naturally depend on how comfortable it is to use. Together with my chosen editor vi, I use mc (Midnight Commander) which is very similar in appearance & function to Norton Navigator, but also includes a built in editor. I find it easier to find & check files in a sort of "visual mode" with mc & then to edit the files, or write scripts, with vi.

Mc is really to use, start it by typing mc, & then you have full access to the file manager & editor through the Function (F1-F9) keys.

Vi is a very powerful editor with many advanced functions. It may be a bit difficult to get used to but it is worth it. Vi has three basic modes, command, edit, & insert.

In the "command" mode you save, quit, search....
In the "edit" (default) mode you can copy & paste, delete whole lines....
In "insert" mode you can alter or type the text....

Once vi is started (vi /path/file), either with a new file or a file to be edited, you enter vi in edit mode. To enter the insert mode just hit the [Insert] key (or push [I])& "insert" will be displayed at the bottom of the screen. You can now change or enter the text as you wish. To leave this mode (back to the default "edit" mode) just push the [Esc] key. To enter command mode from the default edit mode push [:] & the : will be displayed at the bottom of the screen.

Here's a few examples of some of the commands for each of these modes.

Command mode.

:

Enter the command mode.

:w /path/file

Save the file to the name & path specified.

:q

Quit vi, only if the file is unchanged.

:q!

Force quit from vi.

:wq

Save file & quit.



Edit mode.

[ESC]

To leave the other modes & enter the edit mode.

dd

Delete the line being displayed by the cursor.

10 dd

Delete 10 lines beginning with the lines the cursor is on. (chose number as needed)

u

Undo last action.

yy

(Yank) Copy the cursor line into buffer.

10 yy

Copy 10 lines beginning at the cursor. (chose number as needed)

[SHIFT] p

Paste copied lines into the file at the point where the cursor is.

p

Paste to line under cursor.

/search

Search forwards through text for the word "search".

?search

Search backwards through text for the word "search".

n

Repeat the last search command.

N

Repeat the last search command in the other direction.

^

Jump to the beginning of the line.

$

Jump to the end of the line.

[CTRL] u

Page up.

[CTRL] d

Page down.



Keep a list of these common commands handy & you won't have any problems using vi. If it's not your cup of tea then there are a great many other editors out there to try.




back a page    back to main index    forward a page
copyright 2001 Rob Hawke.
rob@highasakite.net