This list of text editors is provided to you courtesy of the ReallyLinux.com
staff. Note that in many cases your version comes with a graphical text editor such as Kate or Kwrite, etc. This section is for those who need to use command line editors. For some lighthearted but encouraging information about Kate (KDE graphical editor) you can read this article.
Text editors are similar to word processors, providing various features for writing documents. Several text editors are available on Linux, and this page explains how to use the three most popular. For information about the specific text editor click on the name below. |
Vi:
Vi is often the default
editor that pops up when you're ready to write an e-mail message or when
you're posting a News message. Vi is complicated and seems difficult
to learn at first. However, it is often the default for Unix and
Linux systems. This chapter explains the use of the Vi editor.
Pico:
Pico is a fairly simple
text editor that provides straight-forward options and easy-to-use commands.
Although some programmers have frowned at Pico's simplicity and limited
options, most folks find that it provides everything necessary to write
long documents with minimal hassles. However, Pico is not very good
when manipulating certain types of files such as making changes to .cgi
files etc.
Emacs:
Emacs falls somewhere between
the straightforward Pico and the complicated Vi. Unlike Vi, you don't
need to switch between modes to perform basic text editing functions.
Sadly, the vast set of powerful commands themselves are difficult to remember.
The Emacs link includes basic information on Emacs for situations where
you may encounter it or for those who use it on an occasional basis.
Vi
Editor
Click on this
link to go to the command summary.
Start the Vi editor by typing vi at the prompt. Typing vi followed by a file name will automatically name the file so you don't have to worry about it later.
On a number of other occasions programs use Vi for text editing. When you post to a News group or send e-mail, the system may default to Vi. How do you know when you're in Vi and when you can use Vi commands?
Vi has two modes: Command mode that lets you use commands to edit, save, or quit; and Text mode that lets you type. If you attempt to do something in the wrong mode, the system beeps furiously at you until you either stop pressing keys or scream (the louder the scream the more beeps you muffle).
Use the Esc
key to change from one mode to the other.
Simple Example of Using Vi:
Vi starts in the Command mode. To switch to text mode press i.
Type out your text. To make corrections, move to a location in your text, or
save your file, switch to the Command mode by pressing Esc.
In command mode you may edit, save, or exit (see Command Mode below
for details).
To switch back to Text mode, type i again. Getting the hang of switching
between modes may take a while, so be patient with yourself.
Occasionally, when you're
typing quickly, some of your text may seem to disappear. Actually
your text is still there, but has become blacked out. This black-out
is usually caused by a slow screen update, and Vi is notorious for this.
Because the information on your screen is coming through your modem, it
needs to be updated (refreshed) occasionally, or parts of the information
disappear from your screen. To update your screen's information,
hold down the Ctrl key and press l (thats an L not a 1) while in the Command
mode. Do this whenever chunks of your text black-out.
Text
Writing Mode
The Vi editor starts in
the Command mode. To switch to the Text mode and begin typing, press
i. If you hear several beeps and you're unable to type, then press
i twice to switch to the text mode.
Command
Mode
Press the Esc key to switch
from Text mode to Command mode.
Moving Around
Saving and Exiting
Editing
Vi Troubleshooting
Trying to use a command
If youre trying to
use a Move, Save, or Edit command but the command isnt working, switch
from Text mode to Command mode by pressing the Esc key.
If the backspace key doesnt work, then hold down the Ctrl key and press backspace.
Trying to save
If you get the message
No current filename, type :w followed by a filename. The message
appears only if a filename has not been specified.
If you get the message
Is a directory, youre trying to write to a directory not a file.
Use a different name for your file to save it properly.
Pico
Editor
Click on this
link to go straight to command summary.
If you have trouble getting access to Pico, briefly review the next chapter, Customizing Your Account. If Pico isnt loading and you want to try it out right away, follow these steps:
At the prompt type: set path=($HOME/bin /usr/local/bin)
Next, press the key.
This is only a temporary setting. To make Pico permanently available, you need to refer to Chapter 8, Customizing Your Account.
Start the Pico editor
by typing pico at the prompt. Typing pico followed by a file name
automatically names the file so you don't have to worry about it later.
Ex: pico newfile.txt
Using Pico is fairly straight-forward. The blinking cursor indicates where you may begin typing. Type out your message without worrying about line breaks or page breaks. Pico takes care of these for you. When you're finished typing, or anytime you're ready to use a Pico command, refer to the Pico menu options, listed at the bottom of the screen.
To use an option, hold down
the Ctrl key and press the letter indicated. The ^ symbol represents
the Ctrl key.
Ex: To use the option
^G Get Help, hold down the Ctrl key (designated by the ^ character) and
press g. Always refer to the bottom two lines of Pico to see what
options are available to you. Depending on what you're doing in Pico,
your options change.
Editing text
You can edit your document
by using the arrow keys and the backspace key on your keyboard.
Sometimes, when you're typing
quickly, your text may seem to disappear. Your text is still there,
but has become blacked out. This black-out is usually caused by a
slow screen update. Because the information on your screen is coming
through your modem, it needs to be updated (refreshed) occasionally, or
parts of the information disappear from your screen. To update your
screen's information, hold down the Ctrl key and press l (thats L, not
the number 1). Do this whenever chunks of text you're working
on become blacked out.
Commands
Movement Commands:
Depending on your system,
the arrow keys or the backspace key may not work. Instead, you can
use these commands to perform the same tasks.
Smorgasbord of Pico Options
^C Cancel allows you to stop a process at any time. If you make a mistake, just hold down the Ctrl key and press c.
^G Get Help
Get clear and concise assistance
from the Pico help, in case something unexpected happens or you need additional
information about a command.
^X Exit
Exit Pico at anytime.
If you've made changes to a file or you've worked on a new file, but you
havent saved the changes, you see this message:
Save modified buffer (ANSWERING
"No" WILL DESTROY CHANGES) (y/n)?
Answering no (press n) will
close Pico and bring you back to the prompt without saving your file.
Answering yes (press y)
will allow you to save the file you've been working on (see WriteOut section
below for details).
^O WriteOut
Save your file without hassles
or worries. Fill in the name of your file beside the File Name to
write: prompt. If your file already has a name, then press enter.
^T To Files option lets you save your text over a file that exists in your directory. By choosing the To Files option, Pico takes you to a directory Browser.
Browser Options
To alter a file or
directory, first use the arrow keys or the optional movement keys (described
on page 32) to highlight a particular name. You can also press w
to find and highlight a file or directory quickly. Once you've highlighted
a particular file or directory, you can use any one of these options.
Type e to Exit the
Browser
Type r to rename a
directory or file
Type d to delete a
file
Type m to create an
additional copy of a file
Type g to move to
another directory where the file is located Type s or press to write over
the file with text you just wrote in Pico
^R Read File
Insert text from another
file into your current text file. This option allows you to search
through your directories for a file that you would like to add to your
text. This option is especially handy if you've saved a document
and would like to add its content to the new file you're working on.
Text from the file you select is placed on the line directly above your
cursor.
At the Insert file: prompt
you may either type a file name or use the Browser options.
^T To Files option lets you import a text file directly into the file you're currently typing. By choosing the To Files option, Pico takes you to a directory Browser.
Browser Options
To alter a file or
directory, first use the arrow keys or the optional movement keys (described
on page xx) to highlight a particular name. You can also type W to
find and highlight a file or directory quickly. Once you've highlighted
a particular file or directory you can use any one of these options.
Type e to Exit the
Browser
Type r to rename a
directory or file
Type d to delete a
file
Type m to create an
additional copy of a file
Type g to move to
another directory where a file for importing may be located
Type s or press to
import a text file directly into your current file
^Y Prev Pg
Move quickly to the previous
page. Although you could just as easily press the up arrow key several
times, this command quickly jumps your cursor up one page.
^V Next Pg
Move quickly to the next
page. Although you could just as easily press the down arrow key
several times, this command quickly jumps your cursor down one page.
^K Cut Text
Cut a line of text.
This option allows you to cut a full line of text. By using the uncut
command and your arrow keys, you can then paste the cut text at another
location in your document. To cut specific text in a line or to cut
several lines of text, first select the text (see Selecting Text on the
next page).
Selecting
Text
To select text for cutting
and pasting use the following steps:
Move the cursor to the beginning of the text you want to select^U UnCut Text
Hold down the Ctrl key and press ^
Use the right arrow key or hold down Ctrl and press f to highlight text
When you have highlighted the appropriate text, hold down the Ctrl key and press k to cut it.
Paste the text you cut, anywhere in your document, using UnCut Text
^C Cur Pos
Indicate the current position
of your cursor, relative to the entire document. This is a helpful
option if you'd like to check exactly where in your document you are.
The status line indicates the following items:
[ line 8 of 18 (44%),
character 109 of 254 (42%) ]
^J Justify
Even out lines of text.
This command is handy when you acciden-tally type extra spaces between
words or press the key before reaching the end of a line. The option
evens the length of your text lines automatically.
^U UnJustify
UnJustify lines of text.
For the messy line look you can always select the UnJustify option.
^W Where is
Find a particular string
of text quickly. This option allows you to do a word search in your
text. This option is especially handy for longer documents.
If the word you designated at the Search: prompt is found, it places the
cursor beside it.
^T To Spell
Check for spelling errors.
The spell check option allows you to correct spelling errors throughout
your document. If spell checker finds a misspelled word or a word
it doesn't recognize (don't worry, this rarely happens), it will
let you correct the word. At the Edit a replacement: prompt, type
in the correct spelling of a word. However, if you don't want to
make any changes, simply press the enter key.
Any words that you've corrected
but re-occur in the document can be automatically replaced. At the
Replace a with b? [y]: prompt press y to replace all occurrences of the
misspelled word or n to ignore.
Start Emacs text editor by
typing emacs at the prompt. Typing emacs followed by a file name
automatically names the file, so you don't have to worry about it later.
If youre in a hurry, turn
the page for Emacs commands.
Emacs doesn't require you
to switch between modes. However, when using Emacs, keep in mind
these things: it's often necessary to press enter before reaching the end
of a line; all of the commands require you to hold down the Ctrl key and
press a letter; and messages that appear are usually loaded with jargon,
so if you don't understand them, ignore them.
Simple Example of Using Emacs:
At the prompt type: emacs
You see a long and dull message appear on your screen. Start
typing your document.
To save your file, hold down the Ctrl key and press x; then hold down the
Ctrl key and press w.
Beside the Write file: ~/ prompt, type the name of your file and press enter.
Ex: Write file: ~/testfile.txt
To quit Emacs, hold down the Ctrl key and press x; then hold down the
Ctrl key and press c.
Emacs Commands
Moving
Saving and Editing
Saving
Editing
Using the movement keys,
locate your cursor in the appropriate spot for editing. Besides using the
Delete key to delete individual characters, you can use the following editing
commands:
Emacs Troubleshooting
Trying
to Search
If there are no other
text strings that match the one youve searched for, you see the message:
Failing I-search backward: flesch. Re-start your search or stop searching.
Trying
to Save
If you try to save
a file that has the same name as a directory, you see the message: File
/usr/u4/mraiszad/test is a directory.
You have to name your file
something else.
Emacs
Tutorial?
An Emacs tutorial is available
on the system. To review the Emacs Tutorial, hold down the Ctrl key
and press h; then press t. To quit the tutorial, hold the Ctrl key
and press x; then hold the Ctrl; and press c.
Refreshing
Missing Characters?
Occasionally, when you're
typing quickly, some of your text may seem to disappear. Actually
your text is still there, but has become blacked out. This black
out is usually caused by a slow screen update. Because the information
on your screen is coming through your modem, it needs to be updated (refreshed)
occasionally, or parts of the information disappear from your screen.
To update your screen's information, hold down the Ctrl key and press l.
Do this whenever chunks of your text black out.
--- the end ---