Archive

Archive for the ‘emacs’ Category

Why GNU Emacs?

February 14, 2016 1 comment
Categories: emacs, Interesting

Learning Emacs – Ch 3 (Word Abbreviation)

April 6, 2011 Leave a comment

Chapter 3 – Word Abbreviation

M-/ (dabbrev-expand) [Complete the word you are typing based on the nearest word that starts with this string (press M-/ again if that’s not the word you want)]

NB. There is a whole lot more. Just felt very advanced, so I left it out.

 
source: “Learning GNU Emacs, 3rd Edition by Debra Cameron, James Elliott, Marc Loy. Copyright © 2005 O’Reilly Media, Inc. ISBN 0-596-00648-9”

Categories: emacs Tags:

Learning Emacs – Ch 3 (Search)

April 6, 2011 Leave a comment

Chapter 3 – Search

A. Searching
1. C-s (isearch-forward) [Incremental search forward]
2. C-s C-s (isearch-repeat-forward) [Find the next occurance of the ]
3. C-r (isearch-backward) [Incremental search backward]
4. C-s C-s (isearch-repeat-backward) [Find the previous occurance of the ]
5. C-g [Cancel command, ie give up searching]
6. C-s C-w (isearch-yank-word ) [Start incremental search using the word that the cursor is on]
7. C-s C-y (isearch-yank-line) [Start incremental search using the text from the cursor position to the end of the line]

B. Search and Replace
1. M-x replace-string Enter “old-word” Enter “new-word” Enter [Replace all occurances of “old-word” with “new-word”]

2. To replace one word at a time.
M-< [move to the beginning of the buffer]
M-% (query-replace) [prompt Query replace: appears in the minibuffer]
Type the search string and press Enter. Emacs searchs for the first occurence of the string. It waits for user input which can be any off

i) Space or y – Replace searchstring with newstring and go to the next instance of the string.
ii) Del or n – Don’t replace; move to next instance.
iii) . (ie fullstop) – Replace the current instance and quit.
iv) , (ie comma) – Replace and let me see the result before moving on. (Press Space or y to move on.)
v) ! (ie exclaimation mark) – Replace all the rest and don’t ask.
vi) ^ (ie carrat) – Back up to the previous instance.
vii) Enter or q – Exit query-replace.
viii) E – Modify the replacement string.

 
source: “Learning GNU Emacs, 3rd Edition by Debra Cameron, James Elliott, Marc Loy. Copyright © 2005 O’Reilly Media, Inc. ISBN 0-596-00648-9”

Categories: emacs Tags:

Learning Emacs – Ch 2 (More editing)

April 5, 2011 Leave a comment

Chapter 2 – More editing

A. Transpose
1. Letters
C-t (transpose-chars) [ change teh – the]
2. Words
M-t (transpose-words) [ change emacs learning – learning emacs]
3. Lines
C-x C-t (transpose-lines)

B. Capitalization
1. M-c (capitalize-word) [Capital]
2. M-u (upcase-word) [CAPITAL]
3. M-l (downcase-word) [capital]

C. Overwrite Mode
1. Press Insert Key or M-x overwrite mode or M-x ov
To turn it off type – M-x overwrite mode again.

D. Cancelling Commands
1. C-g

E. Undoing Changes
1. C-_ or C-x u (undo) [undo changes one by one]
2. M-x revert-buffer Enter [Undo all changes made since you lat saved the file]
3. C-x C-f filename~ Enter C-x C-w filename Enter

F. Recover lost changes
1. M-x recover-file Enter

 
source: “Learning GNU Emacs, 3rd Edition by Debra Cameron, James Elliott, Marc Loy. Copyright © 2005 O’Reilly Media, Inc. ISBN 0-596-00648-9”

Categories: emacs Tags:

Learning Emacs – Ch 2 (Deleting blocks of text)

April 4, 2011 Leave a comment

Chapter 2 – Deleting blocks of text.
(The books summarizes this very nicely)

To mark a region:
1. Move the cursor to the beginning of the area you want to delete.
2. Press C-Space. Emacs displays the message Mark set.
3. Move the cursor to the end of the region you want to delete.

To delete a region:
1. Mark the region to be deleted.
2. Press C-w to delete the region.

To move text:
1. Delete the text you want to move using the procedures for marking and deleting a region.
2. Move the cursor where you want to insert the text.
3. Press C-y. Emacs inserts the text you deleted.

To copy text:
1. Mark the region you want to copy.
2. Press M-w to copy the text.
3. Move the cursor where you want to insert the copied text and press C-y. Emacs inserts the text you copied.

So to

A. Cut text
1. C-Space or C-@ [ to set a mark]
2. C-w (kill-region) [Delete the part you just marked.]

B. Copy text
1. C-Space or C-@ [ to set a mark]
2. M-w [Copy the part you just marked.]

C. Paste text
1. C-y (yank) [ restore what you deleted in this case what was “copied” or “cut” ]

 
source: “Learning GNU Emacs, 3rd Edition by Debra Cameron, James Elliott, Marc Loy. Copyright © 2005 O’Reilly Media, Inc. ISBN 0-596-00648-9”

Categories: emacs Tags:

Emacs Meta key

March 31, 2011 Leave a comment

Typing M-x using one hand was just not working for me. Both Alt keys on the keyboard are meant to behave as a Meta key but mine did not. Turns out that all I had to change was my Keyboard settings. Here is what I did on Ubuntu (Generic Keyboard Layout).

Keyboard Layout options.

  1. Alt/Win Key behaviour
    • Alt and Meta are on the Alt Key
  2. Third Level choosers
    • Press Right Ctrl to choose 3rd level (Previously set to Press Right Alt to choose 3rd level)
    • Press Right Win-Key to choose 3rd level

That worked. Now both Alt Keys behave like Meta.

Categories: emacs Tags:

Learning Emacs – Ch 2 (Editing)

March 30, 2011 Leave a comment

Chapter 2 – Editing

A. Movement
1. Characters
    C-p (previous-line)
    C-n (next-line)
    C-f (forward-character)
    C-b (backward-character)
2. Words
    M-f [forward a word]
    M-b [backward a word]
3. Lines
    C-e [end of the line]
    C-a [beginning of the line]
4. Sentences
    M-a [move backward one sentence]
    M-e [move forward one sentence]
5. Screen
    C-v or PgDown Key [page down]
    M-v or PgUp Key [page up]
6. Buffer
    M-> or End Key [end of a buffer]
    M-< or Home Key [beginning of a buffer]
7. To a specific line
    M-x goto-line Enter n Enter
    M-x goto-char Enter n Enter

B. Repeating Commands
M-n (digit-argument) eg M-500 C-n [move the cursor down 500 times]

C. Deleting Text
C-d (delete-character)
M-d (kill-word)
C-k (kill-line)
M-k (kill-sentence)
C-y (yank) [restore what you deleted]

D. Undo
C-_ or C-x u

 
source: “Learning GNU Emacs, 3rd Edition by Debra Cameron, James Elliott, Marc Loy. Copyright © 2005 O’Reilly Media, Inc. ISBN 0-596-00648-9”

Categories: emacs Tags:

Learning Emacs – Ch 1 (Basics)

March 29, 2011 Leave a comment

Objective: Learn Emacs by reading this book. “Learning GNU Emacs, 3rd Edition By Debra Cameron, James Elliott, Marc Loy”

Chapter 1 – Emacs Basics

Open a file C-x C-f (find-file)
Save a file C-x C-s (save-buffer)
                  C-x C-w [Equivalent of save as]

Quit C-x C-c

Help C-h
        C-h ? [list of options]
        C-h t [tutorial]
        C-h k (describe-key) C-h C-x i [ie describe the key for inserting a file. 
                                                        C-x i (insert-file) ]
        C-h f (describe-function) C-h f find-file
Categories: emacs Tags: