HLUG TWiki > HLUG > ClassFourNotes (r1.1 vs. r1.6) TWiki webs:
AIX| Classes | HALBOD | HLUG | Helpdesk | Library | Main | Samba | TWiki |
HLUG . { Home | Changes | Index | Search | Go }
 <<O>>  Difference Topic ClassFourNotes (r1.6 - 19 Nov 2004 - AaronEstrada)
Changed:
<
<

(Working draft: read at your own risk)

>
>

Changed:
<
<

I've buried the hatchet with emacs, and I see my novice error in vi myopia. It shows that not everything is learned immediately, and that when purpose steers choice, real winners are easy to spot. If you aren't chasing technology, and you have a wide variety of choices in the software you can use, you can focus on what you want, or need from a computer, and find ways to use them in more practical, and personal ways.

>
>

I've buried the hatchet with emacs, and I see my novice error in vi myopia. The rule I apply to distros, is just as applicable to text editors, and that is; No matter which one you choose, stick with it and master it. Once you can manipulate text on the command line, with confidence, you have all the basic tools to work within your command line environment. Everything else is a function of communication, an information sharing. We'll cover these topics, in our later segments. So, that's it for now.

Have fun,

Aaron

P.S. I'd like to thank John Lightsey, for sitting in for me during the actual class, and also Peter Hodgson, for consistently tolerating emacs bashing, without holding a grudge.


 <<O>>  Difference Topic ClassFourNotes (r1.5 - 19 Nov 2004 - AaronEstrada)
Changed:
<
<

Pre-game

>
>

Linux Text Editorial

(Working draft: read at your own risk)
Changed:
<
<

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

>
>

Is it a hack to use a text editor as a word processor?

Changed:
<
<

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

>
>

For the better part of two months, I've been putting together what I thought was going to be a presentation about text editing using the most common Linux editors: vi, and emacs. I was also going to cover another editor, nano, which I find very useful as well. As it turns out, it's not much to talk about. A half-hour consultation of the web tutorials pretty well gets the wheels in motion, and after that, it's just a matter of usage.

Changed:
<
<

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

>
>

After that, I wanted to talk about using text editors as a quasi-word processor. I kicked the tires on all the editors, trying to just blurt out ideas, the way I would with a pen and pad. The results were interesting. All of my efforts have yielded the decision that vi sucks the worst, of three editors. It’s not that there’s anything wrong with vi, it’s mainly a design choice that favors the needs of computer programmers, and the piles of text they shovel around trying to bang out software for us. Unlike poetry and prose, programmers are composing blocks of text that often need to be changed in bulk, or reused extensively. Tools like vi allow the automation of tasks like this, and free up a programmer's attention

Changed:
<
<

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

>
>

Poetry, prose, and grocery lists, are linear material. The writer writes it, the reader reads it. If a writer just copied and pasted a book together out of reused paragraph routines, I’d be pretty disappointed. So, much of technical keystroke magic is buried in vi’s underbelly, never to be used in composition, and without the simple ability to type, and use edit commands simultaneously. In my opinion, juggling the mode functions of vi is distracting when just trying to jot a quick thought.

Changed:
<
<

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

>
>

If the idea of a text editor “with modes” sounds foreign, crack open vi at a prompt, and try writing a quick letter using this cheat sheet.

Added:
>
>

I wish I was a vi hater, but I’m not. In fact, it’s the first, and only text editor I used for years, until I started “feeling creative”. Once I started writing more than configuration blurbs, and manipulating comment marks, I tried to hold on, but could, since I had to keep typing SHIFT+: +26yy, and that sort of thing. I had to kick the habit.

Changed:
<
<

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

>
>

For this reason, I now use nano, or emacs.

Changed:
<
<

# 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'

>
>

Yeah, I use emacs.

Changed:
<
<

# 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'

>
>

Come and get me!

Changed:
<
<

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

>
>

Before you do pick me off, from a rooftop, let me say a few kind words about nano. I launch the software, and just start typing. I get my ideas tapped out, and leave the rest for later. I use emacs the same way, only it takes longer for the software to load. Remember, this is prose, not the next sendmail replacement. Yes, I know it’s strange that I write better, and faster this way, but nevertheless, I have become a firm believer in Linux computers; as genetically modified, ten ton, turbo boosted, future-proof…typewriters. After four years of software sampling, distro bickering, config tweaking, and computer building, this is what open source has yieled for me.

Changed:
<
<

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

>
>

It all started when I decided to buy an oddball laptop, on a trip to Austin. Like all geeks, I thought, well, at least I can run Linux on it. Six months later, it was imprisoned deep within my closet, so as not to remind me of my poor decision making skills.

Changed:
<
<

-- INSERT -- 1,1

>
>

Well, some time later, I need to write some materials, and was not excited about using my work PC for personal stuff. I had to do something, so I put my dying laptop to some real use. It was a decrepid 486 laptop, that never could do X-Windows. It wheezed along with 20 MB of RAM. I stood before it, and thought, it's got to be better than a pencil, and scraps of paper, right? At that moment I promised my laptop, on it's death bed, that I would ressurect it into the world most powerful typewriter. I booted the computer, and after it clicked and burped into consciousness, I installed debian, apt-got nano, and ws off to the races. I fired it up, and found myself happily tapping away at my keyboard. Then I noticed that nano had a usable spell checker, simple cut/paste functionality, and I was sold.

Changed:
<
<

Top


>
>

But, I think I used nano for another reason, though.

Changed:
<
<

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.

>
>

To avoid emacs.

Changed:
<
<

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

>
>

At this time, I was an emacs hater, but why? I think it originally had something to do with mainframes, and modems, but I tried to make it more like good vs evil, as I am a bit dramatic. However, during my research, I forced myself to sit and endure emacs indoctrination. I gave it a fair chance, and was happily surpised. It launched slower than both vi and nano, but once I learned some basic commands, I was plugging along as comfortably as I had in nano. While communing with the savages, I found this cheat sheet, just in case you wanna give it a go.

Changed:
<
<

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'

>
>

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

Deleted:
<
<

[ Read 57 lines ]

Changed:
<
<

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

>
>

After using using emacs a bit, I started getting curious about all the other things it can do, like email, web browsing, and can opening. I felt dirty inside. I opened up vi, inspected my /etc/hosts file, and I felt at ease again. Actually, emacs showed me that even a command line program can be as distracting as modern office applications, if you sig to deep ,or ask too much. In a way, it was the Office, of text editors, and that scared me.

Changed:
<
<

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

>
>

So, to set aside the age-old beef, I'm rolling with the nano, for the purposes of this article. It's cheat sheet is right here.

Changed:
<
<


>
>

http://www.nano-editor.org/dist/v1.2/nano.html

Added:
>
>

I've buried the hatchet with emacs, and I see my novice error in vi myopia. It shows that not everything is learned immediately, and that when purpose steers choice, real winners are easy to spot. If you aren't chasing technology, and you have a wide variety of choices in the software you can use, you can focus on what you want, or need from a computer, and find ways to use them in more practical, and personal ways.

Deleted:
<
<

-- AaronEstrada - 03 Nov 2004


 <<O>>  Difference Topic ClassFourNotes (r1.4 - 09 Nov 2004 - AaronEstrada)
Deleted:
<
<

Like emacs, it let's you edit straightaway, but it has a list of common commands along the screen bottom, so you don't have to fish around. Personally like to use my text editor and screen to handle all of my cutting and pasting, so I don't bother much with the built-ins for this purpose. However, since I haven't gotten to screen yet, let's see which copy and paste function bothers you least.


 <<O>>  Difference Topic ClassFourNotes (r1.3 - 05 Nov 2004 - AaronEstrada)
Added:
>
>

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

Changed:
<
<

environment, sort of a KDE for the console. However, it is alone in this design. I think that this is because it breaks from the utility-centered approach of *NIXes.

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

>
>

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

Deleted:
<
<

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

Added:
>
>

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

Top

Changed:
<
<

This is exactly 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.

>
>

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.

Deleted:
<
<

-- INSERT -- 1,1 Top

Changed:
<
<


>
>

-- INSERT -- 1,1

Changed:
<
<

The bottom of the screen displays -- INSERT --, and you can begin to type. When you are finished, press the ESC button, and you return to command mode.

>
>

Top


Changed:
<
<

The next command is usually to quit, save, or save, then quit. Here are the commands for each.

>
>

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.

Changed:
<
<

emacs .bashrc

>
>

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

Changed:
<
<

File Edit Options Buffers Tools Insert Help

>
>


Added:
>
>

File Edit Options Buffers Tools Insert Help

Changed:
<
<


:---F1 .bashrc
>
>

----:---F1 .bashrc

Added:
>
>

Added:
>
>


Changed:
<
<

As you can see, there is a header, and footer, giving you file information, and a top menu bar. From this main screen you 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:

>
>

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:

Changed:
<
<

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

>
>


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


Changed:
<
<

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. Now that I've gone over that, it is time for a rant. 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 when all you need to do is type something, and save it. Also, unlike a typewriter, both emacs and vi will, by default, allow you to type sentences of almost infinite length. This has to to with word wrapping, margins, and other crap I don't think a user should have to bother with. They don't have to. For me, this is where I switch to nano. It really is easier to use.

>
>

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.

Changed:
<
<

GNU nano 1.0.6 File: .bashrc

>
>

GNU nano 1.0.6 File: .bashrc

Changed:
<
<

[ Read 57 lines ] ^G Get Help ^O Write_Out ^\ 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

>
>

[ Read 57 lines ]

Changed:
<
<


>
>

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

Changed:
<
<

Like emacs, it let's you edit straightaway, but it has a list of common commands along the screen bottom, so you don't have to fish around.

>
>

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


Changed:
<
<

ersonally like to use my text editor and screen to handle all of my cutting and pasting, so I don't bother much with the built-ins for this purpose. However, since I haven't gotten to screen yet, let's see which copy and paste function bothers you least.

>
>

Like emacs, it let's you edit straightaway, but it has a list of common commands along the screen bottom, so you don't have to fish around. Personally like to use my text editor and screen to handle all of my cutting and pasting, so I don't bother much with the built-ins for this purpose. However, since I haven't gotten to screen yet, let's see which copy and paste function bothers you least.


 <<O>>  Difference Topic ClassFourNotes (r1.2 - 05 Nov 2004 - AaronEstrada)
Added:
>
>

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 exactly 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, 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

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 you 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. Now that I've gone over that, it is time for a rant. 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 when all you need to do is type something, and save it. Also, unlike a typewriter, both emacs and vi will, by default, allow you to type sentences of almost infinite length. This has to to with word wrapping, margins, and other crap I don't think a user should have to bother with. They don't have to. For me, this is where I switch to nano. It really is easier to use.


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 Write_Out ^\ 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


Like emacs, it let's you edit straightaway, but it has a list of common commands along the screen bottom, so you don't have to fish around.

ersonally like to use my text editor and screen to handle all of my cutting and pasting, so I don't bother much with the built-ins for this purpose. However, since I haven't gotten to screen yet, let's see which copy and paste function bothers you least.


 <<O>>  Difference Topic ClassFourNotes (r1.1 - 03 Nov 2004 - AaronEstrada)
Added:
>
>

%META:TOPICINFO{author="AaronEstrada" date="1099518480" format="1.0" version="1.1"}% %META:TOPICPARENT{name="WordPlay"}%

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. However, it is alone in this design. I think that this is because it breaks from the utility-centered approach of *NIXes.

-- AaronEstrada - 03 Nov 2004


Topic ClassFourNotes . { View | Diffs | r1.6 | > | r1.5 | > | r1.4 | More }
Revision r1.1 - 03 Nov 2004 - 21:48 GMT - AaronEstrada
Revision r1.6 - 19 Nov 2004 - 16:16 GMT - AaronEstrada
Copyright © 2003-2007 by the contributing authors