Difference between revisions of "Short Emacs Tutorial"
(→Minimalist Set of Commands) |
|||
(5 intermediate revisions by the same user not shown) | |||
Line 19: | Line 19: | ||
Control-X Control-C | Control-X Control-C | ||
− | * | + | * Here are the minimalist set of commands you should learn: |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
<br /> | <br /> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
<tanbox> | <tanbox> | ||
{| style="background:#cccc66" | {| style="background:#cccc66" | ||
Line 101: | Line 65: | ||
|} | |} | ||
</tanbox> | </tanbox> | ||
+ | <br /> | ||
+ | ==Playing with the Emacs Editor== | ||
+ | <br /> | ||
+ | |||
+ | You will now get a copy of a file from a Web URL, and edit it. The file is called '''fulghum.txt''' and is a short story from [http://www.robertfulghum.com/ Robert Fulghum's] book [http://en.wikipedia.org/wiki/All_I_Really_Need_to_Know_I_Learned_in_Kindergarten ''All I really need to know I learned in Kindergarten'']. | ||
+ | |||
+ | To get a copy of this file, type | ||
+ | |||
+ | |||
+ | [aurora]$ '''wget http://cs.smith.edu/dftwiki/media/fulghum.txt''' | ||
+ | |||
+ | |||
+ | followed by the return key. Then edit the file with the command | ||
+ | |||
+ | |||
+ | [aurora]$ '''emacs fulghum.txt''' | ||
+ | |||
+ | |||
+ | Simply work on the first paragraph of the file, and try to straighten it up. I have indicated below, on the right-hand side, which emacs commands you can use to fix the text on your screen. | ||
+ | |||
+ | <!-- [[Image:fulghum_emacs.jpg]] --> | ||
+ | <br /> | ||
+ | <source lang="text"> | ||
+ | Now |Join the lines together | ||
+ | let |(c-e) (c-k) | ||
+ | me | | ||
+ | tell you about Larry Walters, my hero. Walters is | | ||
+ | is is is is is is is is a truck driver, | | ||
+ | thirty-three years old. He is sitting in his lawn | | ||
+ | chair in his backyard, wishing he could fly. For | | ||
+ | as long as he could remember, he wishing he go up. | | ||
+ | as long as he could remember, he wishing he go up. |< several copies of the | ||
+ | as long as he could remember, he wishing he go up. | same line here. Delete | ||
+ | as long as he could remember, he wishing he go up. | them with c-k | ||
+ | as long as he could remember, he wishing he go up. | | ||
+ | To be able to just rise right up in the air and | | ||
+ | see for a long way. The time, money, education, | | ||
+ | and opportunity to be a pilot were not his. Hang | | ||
+ | gliding was too ~!@#$%^&*()_+ dangerous, and any |< Extra characters here! | ||
+ | good | remove them! (c-d) | ||
+ | place |< Here again, Join lines | ||
+ | for | together | ||
+ | gliding | | ||
+ | was too far away. So he he he he he he he |< "he" repeated too many | ||
+ | spent a lot of summer afternoons sitting in his | times. Use Esc-d | ||
+ | backyard in his ordinary old aluminum lawn | | ||
+ | chair--the kind with the webbing and nails. Just |< Change word "nails" | ||
+ | like the one you've got in your backyard. | and replace by "rivets" | ||
+ | | | ||
+ | THE NEXT CHAPTER IN THIS STORY is carried by the |< delete words and retype | ||
+ | newspapers and television. There's old Larry | them in lower case | ||
+ | Walters up in the air over Los Angeles. Flying at | | ||
+ | last. Really getting UP there. Still sitting in | | ||
+ | his aluminum lawn chair, but it's hooked on to | | ||
+ | forty-five helium-filled surplus weather balloons. | In the lines below, find | ||
+ | Larry has a parachute on, a CB radio, a six-pack | every occurrence of ?? | ||
+ | of beer, some peanut butter and jelly sandwiches, | and replace it with the | ||
+ | and a BB gun to pop some of the balloons to come | word indicated in the | ||
+ | down. And instead of being just a couple of | right column. | ||
+ | hundred feet over his neighborhood, he shot up | Use c-s to search for | ||
+ | eleven thousand feet, right through the approach | ?? | ||
+ | corridor to the ?? International |> ?? --> Los Angeles | ||
+ | Airport | | ||
+ | | | ||
+ | Walters is a ?? man. When asked by the |> ?? --> taciturn | ||
+ | press why he did it, he said: "You can't just sit | | ||
+ | there." When asked if he was scared, he answered: | | ||
+ | "Wonderfully so." When asked if he would do it | | ||
+ | ??, he said: "nope." And asked if he was glad |> ?? --> again | ||
+ | that he did it, he grinned from ear to ear and | | ||
+ | said: "Oh, yes." The human race sits in its ??. |> ?? --> chair | ||
+ | On the once hand is the message that says there's | | ||
+ | nothing left to do. And the Larry Walterses of | | ||
+ | the earth are busy tying balloons to their chairs, | | ||
+ | directed by dreams and imagination to do their | | ||
+ | thing. The human race sits in its ??. On the |> ?? --> chair | ||
+ | one hand is the message that the human situation | | ||
+ | is hopeless. And the Larry Walterses of the earth | | ||
+ | soar upward knowing anything is possible, sending | | ||
+ | THIS WORDS SHOULD BE DELETED back the message from |> Delete 5 words | ||
+ | eleven thousand feet: "I did it, I really did it. | | ||
+ | I'm FLYING!" | | ||
+ | | | ||
+ | It's the spirit here thAt counts. The time mAy be |> In this last chapter | ||
+ | long, the vehicle mAy be strAnge or unexpected. | all lower case letters | ||
+ | But if the dreAm is held close to the heArt, And | "a" have been replaced by | ||
+ | imAginAtion is Applied to whAt there is close At | uppercase letters "A". | ||
+ | hAnd, everything is still possible. But wAit! | To change all of them at | ||
+ | Some cynic from the edge of the crowd insists thAt | once, position the | ||
+ | humAn beings still cAn't reAlly fly. Not like | cursor on the first line | ||
+ | birds, AnywAy. True. But somewhere in some | and type the command: | ||
+ | little gArAge, some mAniAc with A gleAm in his eye | | ||
+ | is scArfing vitAmins And minerAl supplements, And | ESC-X replace-string | ||
+ | prActicing flApping his Arms fAster And fAster. | (enter) A (enter) a | ||
+ | | | ||
+ | Robert Fulghum. | ||
+ | |||
+ | </source> | ||
+ | <br /> | ||
+ | |||
+ | When you are done with the modification, or if you want to stop for right now and save your modifications, type C-x C-c, and press y when emacs asks if you want to save the file. | ||
+ | |||
+ | <br /> | ||
+ | Additional commands can be found on [[Emacs_Quick_Reference| this page]]. | ||
+ | <br /> | ||
+ | <br /> | ||
+ | <br /> | ||
+ | <br /> | ||
+ | <br /> | ||
+ | <br /> | ||
+ | <br /> | ||
+ | <br /> | ||
+ | <br /> | ||
+ | <br /> | ||
+ | <br /> | ||
+ | <br /> | ||
+ | [[Category:Bash]] |
Latest revision as of 09:31, 13 September 2015
--D. Thiebaut (talk) 18:41, 12 September 2015 (EDT)
Emacs
Reference
- The page Emacs Quick Reference contains a list of most emacs commands you will ever need.
- There are also many tutorials on the Web on emacs.
Minimalist Set of Commands
- To create or edit a file called filename (replace with name you want to use for your file):
emacs -nw filename
- Then enter text as simply as possible.
- To save the file and exit:
Control-X Control-C
- Here are the minimalist set of commands you should learn:
DEL/Shift Backspace | Delete previous character |
c-d | Delete character at cursor |
Esc-d | Delete word |
c-k | Kill line |
c-a | Go to beginning of line |
c-e | Go to end of line |
c-f | Move cursor 1 character forward |
c-b | Move cursor 1 character backward |
c-p | Move to previous line |
c-n | Move to next line |
c-x c-c | quit emacs and save file |
c-x c-s | save file but remain in emacs |
c-g | GE OUT OF TROUBLE! |
Playing with the Emacs Editor
You will now get a copy of a file from a Web URL, and edit it. The file is called fulghum.txt and is a short story from Robert Fulghum's book All I really need to know I learned in Kindergarten.
To get a copy of this file, type
[aurora]$ wget http://cs.smith.edu/dftwiki/media/fulghum.txt
followed by the return key. Then edit the file with the command
[aurora]$ emacs fulghum.txt
Simply work on the first paragraph of the file, and try to straighten it up. I have indicated below, on the right-hand side, which emacs commands you can use to fix the text on your screen.
Now |Join the lines together
let |(c-e) (c-k)
me |
tell you about Larry Walters, my hero. Walters is |
is is is is is is is is a truck driver, |
thirty-three years old. He is sitting in his lawn |
chair in his backyard, wishing he could fly. For |
as long as he could remember, he wishing he go up. |
as long as he could remember, he wishing he go up. |< several copies of the
as long as he could remember, he wishing he go up. | same line here. Delete
as long as he could remember, he wishing he go up. | them with c-k
as long as he could remember, he wishing he go up. |
To be able to just rise right up in the air and |
see for a long way. The time, money, education, |
and opportunity to be a pilot were not his. Hang |
gliding was too ~!@#$%^&*()_+ dangerous, and any |< Extra characters here!
good | remove them! (c-d)
place |< Here again, Join lines
for | together
gliding |
was too far away. So he he he he he he he |< "he" repeated too many
spent a lot of summer afternoons sitting in his | times. Use Esc-d
backyard in his ordinary old aluminum lawn |
chair--the kind with the webbing and nails. Just |< Change word "nails"
like the one you've got in your backyard. | and replace by "rivets"
|
THE NEXT CHAPTER IN THIS STORY is carried by the |< delete words and retype
newspapers and television. There's old Larry | them in lower case
Walters up in the air over Los Angeles. Flying at |
last. Really getting UP there. Still sitting in |
his aluminum lawn chair, but it's hooked on to |
forty-five helium-filled surplus weather balloons. | In the lines below, find
Larry has a parachute on, a CB radio, a six-pack | every occurrence of ??
of beer, some peanut butter and jelly sandwiches, | and replace it with the
and a BB gun to pop some of the balloons to come | word indicated in the
down. And instead of being just a couple of | right column.
hundred feet over his neighborhood, he shot up | Use c-s to search for
eleven thousand feet, right through the approach | ??
corridor to the ?? International |> ?? --> Los Angeles
Airport |
|
Walters is a ?? man. When asked by the |> ?? --> taciturn
press why he did it, he said: "You can't just sit |
there." When asked if he was scared, he answered: |
"Wonderfully so." When asked if he would do it |
??, he said: "nope." And asked if he was glad |> ?? --> again
that he did it, he grinned from ear to ear and |
said: "Oh, yes." The human race sits in its ??. |> ?? --> chair
On the once hand is the message that says there's |
nothing left to do. And the Larry Walterses of |
the earth are busy tying balloons to their chairs, |
directed by dreams and imagination to do their |
thing. The human race sits in its ??. On the |> ?? --> chair
one hand is the message that the human situation |
is hopeless. And the Larry Walterses of the earth |
soar upward knowing anything is possible, sending |
THIS WORDS SHOULD BE DELETED back the message from |> Delete 5 words
eleven thousand feet: "I did it, I really did it. |
I'm FLYING!" |
|
It's the spirit here thAt counts. The time mAy be |> In this last chapter
long, the vehicle mAy be strAnge or unexpected. | all lower case letters
But if the dreAm is held close to the heArt, And | "a" have been replaced by
imAginAtion is Applied to whAt there is close At | uppercase letters "A".
hAnd, everything is still possible. But wAit! | To change all of them at
Some cynic from the edge of the crowd insists thAt | once, position the
humAn beings still cAn't reAlly fly. Not like | cursor on the first line
birds, AnywAy. True. But somewhere in some | and type the command:
little gArAge, some mAniAc with A gleAm in his eye |
is scArfing vitAmins And minerAl supplements, And | ESC-X replace-string
prActicing flApping his Arms fAster And fAster. | (enter) A (enter) a
|
Robert Fulghum.
When you are done with the modification, or if you want to stop for right now and save your modifications, type C-x C-c, and press y when emacs asks if you want to save the file.
Additional commands can be found on this page.