This week was about Emacs. Emacs is an editor used in UNIX programming. Somebody suggests a possible derivation for the letters in Emacs as "Escape-Meta-Alt-Control-Shift" referring to its use of key  combination commands. Its true in one way but Emacs is actually derived from "Editing MACRoS" - where macro is a piece of programming code that runs in Excel environment and helps automate routine tasks.

The two keys commonly used in Emacs are <Ctrl> and <Alt>. Here in this blog I use C for <Ctrl> and M(Meta) for <Alt> afterwards. Emacs look a different from all other editors. All the way down it has a small area called "mini-buffer". All the commands we type or whatever happens to the file is dispalyed in minibuffer while we play inside the editor. So always always look the mini-buffer.

To use emacs on a file

In the shell type,

emacs <filename>  ($ emacs ~/learning/poem)

Help commands

C-h  --Help command

C-h k  --Help by typing a keystroke

C-h a --Help by typing a pattern(C-h a ispell)

C-h ? --Describe how to use the help

File Reading and Writing Commands

C-x C-f --Find a file

C-x C-s --save the buffer into filename

C-x C-w --save as

Cursor/Screen Movement Commands

These commands are also applicable in shell.

C-a  --Move cursor to beginning of line

C-e --Move cursor to end of line

C-f  --Move cursor to forward one character

C-b  --Move cursor to  one character

M-f  --Move cursor to forward one word

M-b  --Move cursor to backward one word

C-n  --Move cursor to next line

C-p  --Move cursor to previous line

C-v  --Scroll file forward by one screen

M-v  --Scroll file backward by one screen

Mark a Region

C-space or C-@ and the move forward or backward using C-n and C-p respectively

Delete Copy Yank

In Emacs "the conventional Cut" is called Delete; and "paste" is called Yank.

C-d  --Delete character under the cursor

M-d  --Delete the word

C-k  --Kill rest of the line

C-w --Delete a region

C-y  --Yank(Paste)

M-w  --Copy

Some other useful commands

C-g --Keyboard quit

C-/  --Undo

Modes in Emacs

Emacs contains many editing modes that alter its basic behavior in useful ways. Two types of modes. Major mode and Minor mode

Major modes provide specialized facilities for working on a particular file type, such as a C source file , or a particular type of non-file buffer, such as a shell buffer .  Major modes are mutually exclusive; each buffer has one and only one major mode at any time.  

M-x python-mode

M-x c-mode

Minor modes are optional features which you can turn on or off, not necessarily specific to a type of file or buffer. Minor modes are independent of one another, and of the selected major mode.  

M-x tool-bar-mode

M-x ispell-minor-mode

Ispell Mode

My presentation last week was about this mode.This mode is used to check the spellings of a single word or words in a whole buffer.By turning on this mode we can have all the words spelled wrong underlined on-the-fly.

M-x flyspell-mode

Ispell offers us so many different language dictionaries. We can change dictionaries by this command below

M-x ispell-change-dictionary

We can check only the spellings of a particular region as

M-x ispell-region

We can check spelling of whole buffer

M-x ispell-buffer

Here above we can see the options for wrong spelled word "Watr" in the third line. We have to click 2 to get the correct word which is "Water".

Thank you for reading my blog.