Göm meny


To edit a file you need a tool to change it with. Emacs is such a tool and is widley used by programmers when coding. Emacs is started by the UNIX command:

ra>emacs filename &

The '&' sign tells the computer that we want to be able to work in the UNIX window at the same time as we work with emacs. If not given, the UNIX window wouldn't accept input until emacs is terminated.

In our example filename is our file. If the file didn't exist before we started emacs it would be created for us. If the suffix is '.c' emacs will be open in C mode and if it is '.C' the program will open in C++ mode. That means that emacs will intepret the code to display it nicely to you.

Instruction to the commands

C-? means pressing Ctrl and the button ? at the same time.
M-? means pressing the button with the diamond sign at the same time as the button ?.

c-x c-g Interupts current command
-A Very useful when Emacs refuses to do anything
c-h Help
c-x c-s Save
The buffer is saved as a file. If the buffer hasn't been saved before it will ask for a name to be saved under
c-x c-w Save as
The buffer is saved under a name
c-x c-f Open file
If the file exist it will be opened. If it doesn't exist a new buffer will be created.
c-x c-c Kill buffer
The buffer is terminated

Moving around

c-p Go up
c-n Go down
c-f Go forward
c-b Go back
M-f One word forward
M-p One word back
c-e Go to the end of the line
c-a Go to the beginning of the line
M- < Home, Go to the beginning
M- > End, Go to the end
PgUp One page up
PgDn One page down
M-x goto-line Go to a specified line

Edit text

c-d Delete next sign
M-d Delete next word
M-SPC Remove unessesary space around the marker
c-t Change place of two letters
M-t Change place of two words
M-c Capitalize next word
c-k (Kill) Cut
Delete the rest of the line
c-y (Yank) Paste
Insert the latest removed text
M-y (Yank pop) Paste special
Used right after c-y or M-y. Replaces the latest pasted text with the text cut before that
M-SPC Set mark
c-w (Kill region) Deletes the text between the Mark set and the marker
M-w Copy text between Mark set and marker

Search and replace

c-s Search
After you've typed down your search key at the bottom of the window the computer will start looking from the marker
M-% Search and replace
Changes a specified text to a new text. The computer starts replacing from the marker
Subcommands to M-%: (Given when first string is found)
Space Bar Replace and keep looking
. (dot) Replace and stop
Delete (Del) Don't replace, keep looking
! Replace all

Informationsansvarig: Kristina Arkad
Senast uppdaterad: 2015-05-25