Home»Programs»Emacs

Emacs Commands
Created Thursday 03 March 2011
Description 	emacs command 	key sequence 	Note
getting into emacs 	N/A 	emacs [ filename] 	typed at UNIX prompt
leaving emacs 	save-buffers-kill-emacs 	ctrl-x ctrl-c	
stopping emacs 	ctrl-z 	N/A 	
resuming a stopped emacs 	fg 	N/A 	typed at UNIX prompt
save contents of file in current window 	save-buffer 	ctrl-x ctrl-s 	
Note: If ctrl-s locks up your keyboard, type ctrl-q to release it. Type ctrl-x s (NOT ctrl-x ctrl-s) 
to save buffers in that case.
Editing Commands
Description 	emacs command 	key sequence 	Mnemonic

insert character 	self-insert-command 	any char 	to insert, just type
delete character 	delete-char 	ctrl-d 	Delete
delete word 	kill-word 	esc d 	esc for word; ctl for char
delete line 	kill-line 	ctrl-k 	Kill
stop what you are doing, emacs! 	keyboard-quit 	ctrl-g 	
undo previous command 	undo 	ctrl-x u 	Undo


Note: Unlike other editors, the undo command undoes many commands. If you type ctrl-x u twice, you 
will undo the last command, and then the command before that. You will not, like most editors, be 
back at the same place.
Moving Around
Description 	emacs command 	key sequence 	Mnemonic

go to next line 	next-line 	ctrl-n 	Next line
go to previous line 	previous-line 	ctrl-p 	Previous line
go forward one screenful 	scroll-up 	ctrl-v 	
go backward one screenful 	scroll-down 	esc v 	
go to beginning of line 	beginning-of-line 	ctrl-a 	A is beginning of alphabet
go to end of line 	end-of-line 	ctrl-e 	End line
go forward one character 	forward-char 	ctrl-f 	
go backward one character 	backward-char 	ctrl-b 	Backward char
go forward one word 	forward-word 	esc f 	esc for word; ctl for char
go backward one word 	backward-word 	esc b 	esc for word; ctl for char
go to beginning of buffer (file) 	beginning-of-buffer 	esc-$<$ 	
go to end of buffer (file) 	end-of-buffer 	esc-$>$ 	
go to line number 	goto-line 		line Number

Search and Search and Replace
Description emacs command	key sequence	Mnemonic

search for text 	isearch-foward 	ctrl-s 	Search
search backwards 	isearch-backward 	ctrl-r 	Reverse
query search and replace 	query-replace 	esc \% 	

Note: if ctrl-s locks up your keyboard, then an easy solution is to go to the end of the 
file and do a reverse search (ctrl-r).
Cutting and Pasting
Description 	emacs command 	key sequence 	Mnemonic

mark beginning of block 	set-mark-command 	ctrl-@ 	
mark end of block 	(done implicitly by placing cursor at desired position)
put back deleted text 	command-yank 	ctrl-y 	Yank
kill block of text 	kill-region 	ctrl-w 
	
Note: ctrl-y works for any deleted text except text delete with ctrl-d. So, you can ``yank'' deleted 
words or lines (i.e., text deleted with esc d or ctrl-k)
Handling Buffers and Windows
Description	emacs command	key sequence	Mnemonic
get file; put into current window 	find-file 	ctrl-x ctrl-f 	Find file
change to buffer buf 	switch-to-buffer 	ctrl-x b 	Buffer
split current window into 2 	split-window-vertically 	ctrl-x 2 	2 windows
make one emacs window 	delete-other-windows 	ctrl-x 1 	1 window
change to other window 	other-window 	ctrl-x o 	Other window
Note: A buffer is a named area that emacs has reserved for you. It may or may not be displayed currently. 
A window is a buffer that is being displayed on the screen. When I say window in this document, that means 
a frame within your emacs session, not a separate window on your screen. Using two windows, one with your 
compile session and one with your edit session might be very helpful, but if you find it frustrating, don't 
do it until you feel more comfortable.
Getting Help
Description	emacs command	key sequence	Mnemonic
general help command 	(this is a prefix) 	ctrl-x ctrl-h 	Help
do emacs tutorial 	help-with-tutorial 	ctrl-x ctrl-h t 	help command + Tutorial
what's the command for word 	command-appropos 	ctrl-x ctrl-h a 	Appropriate command
getting to the on line manual 	info 	ctrl-x ctrl-h i 	Information
  • Boot Linux from USB. part I

    Multiple boot using GRUB2 from live ISO files located on USB
    Read more ...

  • Boot Linux from USB. part II

    Multiple boot using SYSLINUX from live ISO files located on USB
    Read more ...

  • Tweet update.

    Added tweet on @lloadm
    Read

Responsive image