Monday, March 31, 2014

Tips for beginners

Tips for beginners

In the event of an emergency…

Here's what to do if you've accidentally pressed a wrong key:
  • If you executed a command and Emacs has modified your buffer, use C-/ to undo that change.
  • If you pressed a prefix key (e.g. C-x) or you invoked a command which is now prompting you for input (e.g. Find file: …), type C-g, repeatedly if necessary, to cancel.
C-g also cancels a long-running operation if it appears that Emacs has frozen.

Keyboard and terminal setup

  • Some Emacs users remap their Caps Lock key to act as an additional Ctrl key, because it is easier to reach. See instructions for moving Ctrl.
  • Due to your keyboard or terminal configuration, you may find that some keys seem to do the wrong thing:
  • If your DEL key is not working (sometimes, typing DEL brings up a help screen, as if you typed C-h), try M-x normal-erase-is-backspace-mode.
  • If your meta key is not working, in order to type a key that contains meta, you can instead type ESC, then the remaining keys. For example, ESC x is the same as M-x, and ESC C-s is the same as C-M-s.

Exiting Emacs,Fixing Mistakes and other Important Stuff

 Exiting Emacs,Fixing Mistakes and other Important Stuff


C-x C-c

Save-buffers-kill-emacs: when you are finished
 editing, and to return you to the UNIX prompt.
C – g


Keyboard-quit: if while typing a command you
 make a mistake and want to stop, this aborts a 
command in progress.
C- u



Universal- argument: if you want to do a command
 several times, type this command followed by a 
number ( for the number of times) folllowed by the command you wish repeated.




C – x  u

Undo: undoes the last command typed, in case you
 made a mistake.
Esc  x



Execute-extended-command: prompts for the name
 of an emacs command; allows you to execute a 
command if you know roughly what it is called but
 cannot remember the key strokes for it.

Window and buffer commands

 
                             Window and buffer commands

C – x    0
Zero-window: deletes current window
C – x    2
Double-window: Splits current window into
 two parts, allowing you to edit at two different locations in the same file or permitting you to view different files at the 
same time.
C – x    b
Switch-to-buffer: display a different buffer on
 the screen.
C – x    o
Other-window: Move the cursor to the other 
window( Assuming that you have two 
 windows/buffers open at once
C – x    c – b
List-buffers: lists those buffers currently
 loaded into emacs.


Search command

                   Search command

C- s
isearch-forward: prompts for text string and then searches
  from the current cursor position forwards in the buffer.
C – r
Isearch-backward: like isearch-forward, but searches from
 the current cursor position to end of buffer for text string.
Esc %
Query-replace: prompts for a search string and a string with
 which to replace the search string.

Copy and delete commands II


C – w
Kill-region:  delete the area of text between the mark and the
 current cursor position.
C – y
Yank:  insert at current cursor location whatever was most
 recently deleted.
Esc w
Copy-region-as-kill:  Copy area between mark and cursor
 into kill-buffer so that it can be yanked into someplace else.

Copy And delete commands

                  Copy and delete Commands
  
C – d
Delete – char : delete character under
 cursor
Esc d
Delete – word : delete from cursor to 
end of word immediately ahead of the 
cursor.
C – k
Kill – line : Delete the rest of the current line.
C - @
Set-mark-command: Mark is used to indicate the beginning of an area of text to be Yanked
                                                                 EMAC                  

—*Emacs Text editor is a popular & powerful program that is available on many platforms. Ex: UNIX, DOS, Windows 9x and NT, and  OS/2.
—*Emacs -extensible, customizable, self-documenting real-time display editor-GNU
*—Unlike vi, emacs is not an insertion mode editor, -character typed in emacs is automatically inserted into the file.
   
                                             FEATURES
 1.simpler to use than vi
2.editing and viewing multiple files at one time
3.spell checking
4.compiling programs from within Emacs
5.automatic indention of programs
6.a powerful macro language that may be used to extend the functions of Emacs
                                    Emacs-History
1. Emacs -created by Richard Stallman in 1975.
—2.GNU Emacs is the most popular version of Emacs and is directly derived from Stallman's original version.
3.The GNU (Gnu is Not UNIX) project - associated with Stallman's Free Software Foundation.
4.There are other versions of Emacs that are not free.

                                  How to Start

1.To run Emacs, type at the UNIX prompt :
            emacs  file_to_edit
2. Emacs will be run and start editing the file specified.
                   
                          BASICS   

1.         The mode line is the one that is next to the last line from  the bottom and will be highlighted.
2.—       This line divides the editing portion of the screen from the command line at the very bottom.
3.—      When a file is loaded into Emacs, it is loaded into a buffer. Buffers are edited, not files.
—4.     The mode line shows the name of the buffer.
5.—     To update the actual file, the buffer must be saved.
—6.      Emacs will prompt the user to save any modified buffers when it exits.
7.      Emacs maintains a backup file when a file is saved. The backup file is a copy of the last version of the file.
8.—       Its name is the original file name with a tilde (~) appended to the end.
9.—     One other distinction between emacs and vi is that emacs allows you to edit several files at once.
10.—   The window for emacs can be divided into several windows, each of which contains a view into a buffer.
11.—   Each buffer typically corresponds to a different file.

                         Emacs commands

The user uses special keys to send commands to Emacs.
—* Commands in emacs are either control characters (hold down the <Ctrl> key while typing another character) or are prefixed by one of a set of reserved characters: <Esc> or <Ctrl>-X.
*— The (Meta Key) <Esc> key can be typed by itself (because it really is a character) and then followed by another character;
—*The <Ctrl> key must be held down while the next character is being typed.