Archive for the ‘Emacs’ Category

Emacs — ispell — No word lists (Ubuntu)

November 16, 2008

In Ubuntu, if you get:

Error: No word lists can be found for the language “en_US”.

when trying to start ispell (e.g., M-x ispell-buffer) from Emacs, then you need to install the aspell-en package:

sudo apt-get install aspell-en

Emacs — Using rectangles

November 12, 2008

In Emacs, you can not only select by lines, but also by columns. If you select by columns, the selection is called a rectangle. You can use rectangles with the following shortcuts:

  • C-@ or C-Space — start selection (as usual)
  • M-x delete-rectangle or C-x r d — delete the rectangle delimited by the start selection and the current cursor position
  • M-x kill-rectangle or C-x r k — then you can use — M-x yank-rectangle or C-x r y
  • M-x clear-rectangle or C-x r c — replace the contents of the rectangle with spaces
  • M-x open-rectangle or C-x r o — insert spaces in the area and push the original contents to the right

Emacs — Search/Replace new line

March 24, 2007

In order to search/replace new line character (\n) in Emacs, instead of \n you need to type:

C-q C-j

Emacs – change case

February 6, 2007

In order to change the case in Emacs you can use:

M + l to change to lowercase all the letters from the cursor to the end of the word
M + u same meaning, but upercase
M + c same meaning, but capitalizes

Emacs – file coding system

October 11, 2006

In order to change the coding system for a file (i.e., DOS to Unix), you can use:

C-x RET f unix

Emacs – Highlight selected text

September 30, 2006

In order to set emacs to highlight the block of text selected using C-SPACE, add the following to your .emacs file:

(transient-mark-mode t)

See also Delete selected text.

Emacs – Simple comment syntax

September 30, 2006

If you are editing a type of file that has a simple comment syntax (e.g., lines that start with # are considered comments), you can let emacs know about it and get ride of the “No comment syntax is defined” error message when you try to comment a block of text.

Here is what you have to do (we asume that lines that start with # are considered comments):

M-x conf-unix-mode RET
M-: (setq comment-start “#”) RET

Emacs – tabs

August 28, 2006

To make an emacs mode forget about the indentation rules and insert tabs whenever you press the TAB key, add this to your .emacs file:

(define-key html-mode-map (kbd “TAB”) ‘self-insert-command); # only in html-mode

If you don’t really want tabs, but spaces to be inserted whenever you press the TAB key, add this to your .emacs file:

(define-key html-mode-map (kbd “TAB”) ‘tab-to-tab-stop); # only in html-mode

Make sure to call the above function in a mode hook.

You might also want to edit the size of each tab, so use:

M-x edit-tab-stops

For more info:

Emacs – M-x shell color

August 18, 2006

> Any idea how to set the color of the shell prompt in emacs?
> Not sure how much of this has to do with my windowing system (Windows
> XP) and shell (putty) or version of emacs and host.

I don’t think you’ll get ANSI color in your Emacs terminal unless you have this:

;; Add color to a shell running in emacs ‘M-x shell’
(autoload ‘ansi-color-for-comint-mode-on “ansi-color” nil t)
(add-hook ‘shell-mode-hook ‘ansi-color-for-comint-mode-on)

Then set the colors:

;; custom-set-faces was added by Custom — don’t edit or cut/paste it!
;; Your init file should contain only one such instance.
‘(comint-highlight-prompt ((t (:foreground “white”)))))

Emacs — Tab vs. Space

August 17, 2006

To force Emacs to insert spaces instead of tabs when you press the TAB key:

M-x set-variable<RET> indent-tabs-mode<RET> nil

Or in your .emacs file:

(setq-default indent-tabs-mode nil)

For more info: