User Tools

Site Tools

Return to Home page


Usefull commands and configuration scripts for the emacs text editor:


  • C-h f documentazione di una funzione
  • C-h m documentazione del major mode attuale
  • C-h r emacs manual info
  • C-h t emacs interactive tutorial
  • C-h w dice la scelta rapida associata al comando
  • C-h F ricerca le info di un comando
  • C-h a cerca un comando con espressione regolare

Common commands

  • M-x revert-buffer reload an open file (a more fast trick is to use the command C-x C-v <RET> )


  • C-x r s r Copy region into register r
  • C-x r i r Insert text from register r
  • M-x append-to-register <RET> r Append region to text in register r
  • M-x prepend-to-register <RET> r Prepend region to text in register r
  • C-x r r Copy Rectangle into register r
  • C-x r k Kill Rectangle
  • C-x r t string <RET> Replace each line rectangle with string

Registers and Bookmarks (to save and jump in specific positions of the file)

  • C-x r SPC r Save position of point in register r
  • C-x r j r Jump to the position saved in register r
  • C-x r m RET Set the bookmark for the visited file, at point
  • C-x r m bookmark RET Set the bookmark named bookmark at point
  • C-x r b bookmark RET Jump to the bookmark named bookmark
  • C-x r l List all bookmarks
  • M-x bookmark-save Save all the current bookmark values in the default bookmark file


  • C-x v i Register a file for version control
  • C-x v v Commit a modified file that is already registered for version control. C-c C-c to save the revision comment and commit the change.


  • M-l Convert following word to lower case — M-u Convert following word to upper case
  • M-c Capitalize the following word
  • C-x C-l Convert region to lower case — C-x C-u Convert region to upper case
  • M-% Substitution of a string

File management (Dired mode)

How to use emacs to manage file in your harddisk

With C-x C-f or C-x d you can open a directory

Now you can use on the file or on the directory where the cursor is located the following commands:

  • Enter Open the file
  • q Close the directory
  • C Copy the file
  • R Rename the file
  • D Delete the file
  • + Create a new dir
  • Z Compress/decompress the file by gzip

To act on a set of files or directories you can use the following commands to mark them:

  • m Mark a file/directory
  • u Unmark a file/directory
  • U Unmark all marked files/directories
  • % m Mark a files/directories using a regular expression

To refresh the listing of files or directories can be used the g key, and the key ^ can be used to go to the parent directory. As for any emacs environment, you can use the M+! (or M-x shell-command) to run a shell command and use more powerful tools such as awk, find, sed or grep.

Install a new language

For example the Italian language using Ubuntu

Download the new language from the Ubuntu repository:

sudo apt-get install iitalian

Load the downloaded language in emacs with the command:

  • M-x ispell-change-dictionary

Activate, if needed, the automatic correction:

  • M-x flyspell-mode

To check the lessical correctness of the current buffer use the command:

  • M-x flyspell-buffer

The Italian language case

The Italian language is not properly recognized by the ispell dictionary, therefore is better to install aspell.

To install aspell in Ubuntu linux, install the following packets from Ubuntu repository:

sudo apt-get install aspell aspell-it

Now, the .emacs file located in the home directory must be modified in order to setup aspell as the emacs default dictionary. Add to the .emacs file the following lines:

(setq ispell-program-name "aspell") 
(setq ispell-list-command "list")
(setq ispell-dictionary "italiano");; use the Italian dictionary 

the last row must be deleted in the case you do not want that the default dictionary is Italian.

The command explained before for ispell also works for aspell: M-x ispell-change-dictionary, M-x flyspell-mode and M-x flyspell-buffer.

NB: The installation of the Italian dictionary in emacs has been also explained in Italian here

Generate TAGS file

With this command you can generate TAGS file which contains indexes of all symbols in the project.

find . -type f -iname "*.[ch]" | etags -

For example, in emacs with the M-. command you can search the definition of a function or of a structure starting from its calling or use.

If you found any error, or if you want to partecipate to the editing of this wiki, please contact: admin [at]

You can reuse, distribute or modify the content of this page, but you must cite in any document (or webpage) this url:
/web/htdocs/ · Last modified: 2024/04/08 22:35 by

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki
Privacy Policy