HLUG TWiki > HLUG > PresentationCalendar > TopicalVacation > WordPlay > ClassFourNotes (r1.4) TWiki webs:
AIX| Classes | HALBOD | HLUG | Helpdesk | Library | Main | Samba | TWiki |
HLUG . { Home | Changes | Index | Search | Go }

Pre-game

Before we get started, here are links to some online documents I've been using for reference.

http://www.theregister.co.uk/2003/09/11/bill_joys_greatest_gift/

http://c2.com/cgi/wiki?EmacsVsVi

http://www.gnu.org/software/emacs/emacs.html#Whatis

http://dsl.org/cookbook/cookbook_14.html#SEC188

http://graphicdesign.about.com/library/weekly/aa031998.htm

http://www.linuxgazette.com/issue22/words.html

http://sunsite.uakom.sk/sunworldonline/swol-10-1995/swol-10-software.html

For those just trying to get a quick fix, here are the links to the vi and emacs cheat sheets.

http://rgrjr.dyndns.org/emacs/emacs_cheat.html

http://www.colostate.edu/services/acns/bulls/ed03.pdf

http://www.kcomputing.com/kcvi.pdf

Remington Steel

I like to say that if nothing else, Linux is an industrial nonlinear typewriter. Truly, for many, the purchase of a personal computer often is the result of wanting to be able to generate correspondance, and personal expression. Knowing that your computer may never crash is one thing, knowing that by not failing it can record and store your ideas is a whole different matter. Many will tell you that vi, emacs, and other Linux text editors are great for editing configuration files, and this is true.

However, they also provide a simple, responsive way to document your ideas. The bulk of this class will deal with getting on your feet with Linux text editors, and using this as a springboard to begin creating files on your conmputer, and making use of alll that virtual storage space. It may be recipies, addresses, a diary. These are the stuff that, when stored, and backed up, endear you to your computer. Now, for those from the word processing world, some of the ideas I pitch sound crazy. Using a text editor after years of using, say Word, is a bit like quiting smoking cold turkey, but if you are like me, it may strip away the distractions from your eyes, and let you focus on your ideas.

I'll start by describing some background on the history of text editors, and why some people so ardently oppose one, or the other, in the choice of vi or emacs. First of all vi was created in 1976, as was emacs. This was a time when remote connections to mainframes meant 300 baud modem lines. If you wanted to edit some text, vi allowed you to do so with commands that could process the text in bulk, while you wait, since the link was so slow. You could type or edit, but not both simultaneously, as the terminal screen could not respond quickly enough. emacs was typically run over faster connections, on faster computers, in computer labs, so it was more liberal in it's design allowing text entry and manipulation to occur at the same time.

So it went that these two ways of computing created two camps that lived long past the days of slug-slow modems. Today, most people can run either editor with perfect responsiveness on just about any modern computer, but their distinct designs still draw different crowds. I personally started with vi. I suspect that many people get roped into one or the other, pretty much against their will, when they are quite wet behind the ears. So naturally, I think that vi is easier to use. Had I started with emacs, I might see things a litle differently. Nevertheless, vi is actually a significantly smaller application than emacs, and on with a single prupose, text editing.

emacs, on the other hand, grew over time, into a command-line environment, sort of a KDE for the console. emacs can read email, newgroup posting, surf the web, and make you feel superior to vi users.

Before I get started comparing and contrasting, let me say one important thing. When I write up documents for a class, or when I'm getting materials ready for a presentation, I don't use emacs or vi. I use nano. For my purposes it is much better suited for traditional writing, it display key commands on the bottom of the screen, it wraps words by default, and has spellchecking functionality. Try, as I might, both emacs and vi frustrate me whenever I try to use them in this way. However, I like using the crafty vi editing commands, so I generally use it to manipulate files during system admin tasks. I still don't know what to do with emacs. It's also worth noting that manipulation of shell programs is definitely better served by the likes of vi and emacs. So, I think of it in this way. Nano for expression, vi for grunt work. So let's talk about grunt work. Even if you are not root on your Linux system, there are lots of config files you can change to make your environment more personalized. This is the perfect job for a text editor, like vi. Take the .bashrc file, for example. Here's mine

To open it, I type this command:

[05:50pm]@lowtop:$ vi .bashrc

and get this output:


# ~/.bashrc: executed by bash(1) for non-login shells. # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) # for examples

# If running interactively, then: if [ "$PS1" ]; then

# don't put duplicate lines in the history. See bash(1) for more options # export HISTCONTROL=ignoredups

# enable color support of ls and also add handy aliases eval `dircolors -b` alias ls='ls --color=auto' #alias dir='ls --color=auto --format=vertical' #alias vdir='ls --color=auto --format=long'

# some more ls aliases #alias ll='ls -l' #alias la='ls -A' #alias l='ls -CF' # alias date='date +%D' alias nano='nano -s ispell' alias mutt='mutt -f pop://pop-server.houston.rr.com' alias wavr='wavr -f $(date +%s).wav -r 44100 -c 2 -d 16 -m'

# set a fancy prompt PS1='[\@]@\h:\$ '

# If this is an xterm set the title to user@host:dir

".bashrc" 57L, 1477C 1,1

Top


This is what the editor looks like. In vi, you can't just start typing. Remember, vi has different modes, in this case, it is waiting for a command, sort of like a shell. To begin typing, I press "i", to insert text.


# ~/.bashrc: executed by bash(1) for non-login shells. # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) # for examples

# If running interactively, then: if [ "$PS1" ]; then

# don't put duplicate lines in the history. See bash(1) for more options # export HISTCONTROL=ignoredups

# enable color support of ls and also add handy aliases eval `dircolors -b` alias ls='ls --color=auto' #alias dir='ls --color=auto --format=vertical' #alias vdir='ls --color=auto --format=long'

# some more ls aliases #alias ll='ls -l' #alias la='ls -A' #alias l='ls -CF' # alias date='date +%D' alias nano='nano -s ispell' alias mutt='mutt -f pop://pop-server.houston.rr.com' alias wavr='wavr -f $(date +%s).wav -r 44100 -c 2 -d 16 -m'

# set a fancy prompt PS1='[\@]@\h:\$ '

# If this is an xterm set the title to user@host:dir

-- INSERT -- 1,1

Top


The bottom of the screen displays -- INSERT -- , and you can begin to type. When you are finished, press the ESC button, then ":", and you return to command mode. The next command is usually to quit, save, or save, then quit. Here are the commands for each.

save w quit q quit and don't save q! save and quit wq of SHIFT ZZ

This is the barebones of using vi. Later on we'll try out the editing commands.

To do this same thing in emacs, we use this command

[05:50pm]@lowtop:$ emacs .bashrc

This is the output we get.


File Edit Options Buffers Tools Insert Help

# ~/.bashrc: executed by bash(1) for non-login shells. # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) # for examples

# If running interactively, then: if [ "$PS1" ]; then

# don't put duplicate lines in the history. See bash(1) for more options # export HISTCONTROL=ignoredups

# enable color support of ls and also add handy aliases eval `dircolors -b` alias ls='ls --color=auto' #alias dir='ls --color=auto --format=vertical' #alias vdir='ls --color=auto --format=long'

# some more ls aliases #alias ll='ls -l' #alias la='ls -A' #alias l='ls -CF' # alias date='date +%D' alias nano='nano -s ispell' alias mutt='mutt -f pop://pop-server.houston.rr.com' alias wavr='wavr -f $(date +%s).wav -r 44100 -c 2 -d 16 -m'

# set a fancy prompt PS1='[\@]@\h:\$ '

----:---F1 .bashrc

(Shell-script[bash])--L27--Top--------------------

Beginning of buffer


As you can see, there is a header, and footer, giving you file information, and a top menu bar. From this main screen can begin editing immediately, since emacs is modeless, unlike vi. What is tricky after you've entered some text, is figuring out how to save and exit, or just save, or not save and exit. This is because emacs uses keystroke command sequences to operate on text, and change emacs' functionality. Almost all keystrokes start with the use of the control key. I have learned, quite nervously, and awkwardly, that the sequence CTRL-x CTRL-c gets me this prompt, at the bottom of the emacs screen:


Save file /home/lugnut/.bashrc? (y, n, !, ., q, C-r or C-h)


The options are pretty self-explanatory, getting to them is not.

The sequence ESC ESC will get you out of any commands you are trying to back out of, so I've had plenty of chances to use it. Of note, is the CTRL-h option; this gets you to the help page. I personally seem to stuck a lot, so ESC ESC saves my butt a lot.

Both emacs and vi have tutorial modes, so when you find yourself gravitating to one, try the tutorial to get deeper into it. Also a handy cheat sheet link will be provided for each editor.

Since this series of classes is not geared toward programmers, or sysadmins, what I've just covered is the bulk of what you need to know. emacs and vi have lots of features that can work magic on text, but it's just no good, in my opinion, when all you need to do is type something, and save it. Of course, many would argue that a wordprocessor is the proper doamin for such activity, but our series is totally dedicated to a text computing environment, so that's just not in the cards. Instead, I will very briefly cover nano, another text editor. It lacks the extensive powers, and add-on faetues of vi/emacs, but is very usable to shoot off quick text files. To open a file type the command:

[05:50pm]@lowtop:$ nano .bashrc

You should get output similar to this.


GNU nano 1.0.6 File: .bashrc

# ~/.bashrc: executed by bash(1) for non-login shells. # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) # for examples

# If running interactively, then: if [ "$PS1" ]; then

# don't put duplicate lines in the history. See bash(1) for more options # export HISTCONTROL=ignoredups

# enable color support of ls and also add handy aliases eval `dircolors -b` alias ls='ls --color=auto' #alias dir='ls --color=auto --format=vertical' #alias vdir='ls --color=auto --format=long'

# some more ls aliases #alias ll='ls -l' #alias la='ls -A' #alias l='ls -CF' # alias date='date +%D' alias nano='nano -s ispell' alias mutt='mutt -f pop://pop-server.houston.rr.com' alias wavr='wavr -f $(date +%s).wav -r 44100 -c 2 -d 16 -m'

[ Read 57 lines ]

^G Get Help ^O WriteOut ^\ Replace ^Y Prev Page ^K Cut Text ^C Cur Pos

^X Exit ^R Read File ^W Where Is ^V Next Page ^U UnCut Txt ^T To Spell


-- AaronEstrada - 03 Nov 2004

Topic ClassFourNotes . { Edit | Attach | 5B%5EA-Za-z%5D">Ref-By | Printable | Diffs | r1.6 | > | r1.5 | > | r1.4 | More }
Revision r1.4 - 09 Nov 2004 - 00:12 GMT - AaronEstrada
Parents: PresentationCalendar > TopicalVacation > WordPlay
Copyright © 2003-2007 by the contributing authors