emacs for beginner

What is this?

I was eager to learn emacs editor some times back. One fine day started with emacs by just typing “emacs” in command prompt; but did not know how to come out of emacs and also not able to type anything useful – 🙁 🙁 . As usual typed “man emacs” and came to know that “Ctrl+h t” is the best way to browse through the beginner manual; did the same and learned some basics. waavv..! amazing editor!! Now I like its power of simplicity and less keystrokes which makes typing faster. It seems to be more ergonomic design also. This writing is just another simplification of that manual which may help beginner to proceed like cake walk.

Now let us go through some simple tips to start using it. Since I am already a vi user (used with this great editor), I use to confuse myself many times with that. So, If you don’t know vi, well and good so that you can remember these key combinations very well 🙂

File operations:

To begin emacs: Type “emacs ” in shell prompt.
To end emacs: Ctrl+x Ctrl+c (Type these in sequence)
To abort current command: Ctrl+g (If you don’t know what is happening in screen, this command may help you mostly)
Save a file: Ctrl+x Ctrl+s
Save a file as: Ctrl+x s

Moving around file:

1. Ctrl key operates on Characters and Lines.
2. Alt key operates on Words, Sentences and Paragraphs.
3. Easy to remember first letter of functionality such as “n” for next and “p” for previous.

Beginning of file: Alt+Shift+
Page down: Ctrl+v
Page up: Alt+v

(P)revious Line: Ctrl+p
(N)ext Line: Ctrl+n
(B)ackward one Character: Ctrl+b
(F)orward one Character: Ctrl+f
Beginning of a Line: Ctrl+a ( Hint: “a” is the beginning of alphabets)
(E)nd of a Line: Ctrl+e

(B)ackword one Word: Alt+b
(F)orward one Word: Alt+f
Beginning of a Sentence: Alt+a
(E)nd of a Sentence: Alt+e

Repetition of commands: Ctrl+u
(e.g): To move 8 characters forward Ctrl+u 8 Ctrl+f

Editing file:

To insert and delete: Just type the characters and use DEL and BackSpace keys.
Undo: Ctrl+x u
To repeat a character n times: Ctrl+u n
(e.g): To repeat * 80 times to type a border: Ctrl+u 80 *

Delete a character next to cursor: Ctrl+d (or DEL)
Delete a character prior to cursor: BackSpace
Delete a word next to cursor: Alt+d
Delete a word prior to cursor: Alt+BackSpace
Delete from current cursor to end of line: Ctrl+k
Delete from current cursor to end of sentence: Alt+k
Bring back the recently deleted text: Ctrl+y
Bring back the one but latest deleted text: Alt+y

Search a string: Ctrl+s and type search string (Press Ctrl+s for next found)
Search and Replace: Alt+x ; You will get a prompt, enter “repl” and press ENTER, prompt will appear for search string and replace string. That is it. Done!

Share this post

One comment

Leave a Reply

Your email address will not be published. Required fields are marked *