Emacs + TypeRex reminder
Generic Emacs Bindings
MCSC-x C-c
C-g
M-x command
C-h b
Meta modifier (usually Alt or Esc key)
Control modifier
Shift modifier
exit Emacs
abort current command
call function command
describe all key bindings
File Manipulation
C-x
C-x
C-x
C-x
C-x
C-x
C-f
C-s
C-s
b
b TAB
k
open a new file
save current file
save to new file
switch between opened files
list opened files and switch
close current file
Windows (= horizontal/vertical splitting)
C-x
C-x
C-x
C-x
C-x
2
3
o
0
1
split window horizontally
split window vertically
switch focus between splitted windows
unsplit by deleting current window
unsplit by deleting all other windows
Frames (= window-manager windows)
C-x 5 f
C-x 5 b
C-x 5 0
open file in new frame
switch to opened file in new frame
close current frame
Navigation (text)
C-a
/ C-e
C-Home / C-End
C-← / C-→
C-↑ / C-↓
M-g g
M-x goto-char
C-l
beginning/end of line
beginning/end of file
backward/forward one word
backward/forward one paragraph
go to line number
go to char number (from file beginning)
center window on current position
Editing
C-_
C-t
M-t
C-k
C-DEL / M-d
C-backspace
undo last operation
permute two letters
permute two words
cut end of line (as many times as needed)
cut end of word
cut beginning of word
Selection (copy and paste)
C-Space
M-w
C-w
C-y
M-y
start selecting text
copy selection
cut selection
paste selection
circulate between selections (after C-y)
c 2011 OCamlPro SAS — http://www.ocamlpro.com/
February 21, 2012 — Copyright Search and Replace
C-s
C-r
M-x replace-string
M-x replace-regexp
M-%
C-M-%
incremental forward search
incremental backward search
replace string
replace regexp
query before replacing string
query before replacing regexp
Compiling
C-c C-c
C-x ` / C-g p
C-g p
compile
go to next error
go to previous error
Usefull functions
M-x
M-x
M-x
M-x
revert-buffer
grep
diff
shell
re-read from file
find occurrences
find differences
start shell in a buffer
Emacs TypeRex Configuration
Just run cat emacs.append >>~/.emacs and edit the settings.
Sample ∼/.emacs file
;; Loading TypeRex mode for OCaml files
(add-to-list ’load-path "~/.emacs.d")
(add-to-list ’auto-mode-alist
’("\\.ml[iylp]?" . typerex-mode))
(autoload ’typerex-mode "typerex"
"Major mode for editing Caml code" t)
(setq ocp-server-command "/home/me/bin/ocp-wizard")
TypeRex Key Bindings
M-x typerex-help
C-o
show all bindings
show new C-o -prefixed commands
Using type information
(code must be compiled with -annot for the last three)
C-o c
show type and comments for current ident
C-c C-t
show type of current expr. or pattern
C-c C-l
show binding point of current ident
C-c C-f
show kind of current function call
Interaction with the Toplevel
C-c C-s
typerex-run-caml
C-x C-e / C-c C-e
typerex-eval-phrase
C-c C-b
typerex-eval-buffer
C-c C-r
typerex-eval-region
C-c `
typerex-interactive-next-error-source
C-c C-k
typerex-kill-caml
Navigation (OCaml)
C-M-↓ / C-M-n / C-c C-n / C-c C-↓
next phrase beginning
C-M-↑ / C-M-p / C-c C-p / C-c C-↑
previous phrase beginning
C-c home
beginning of enclosing module or class
C-c C-a
switch between .ml/.mli files
C-o a
cycle through connected definitions
C-o d
go to definition of current ident
C-o g
grep current ident
C-o t g
grep current toplevel module
;; TypeRex mode configuration
Inserting Constructions
(setq typerex-in-indent 0)
(setq-default indent-tabs-mode nil)
C-c . l
let . in
(setq ocp-menu-trigger [mouse-3])
C-c . m
match . with
(add-to-list ’load-path "~/.emacs.d/auto-complete-mode") C-c . t
try . with
(setq ocp-auto-complete t)
C-c . f
for . do done
(setq auto-complete-keys ’ac-keys-backquote-backslash)
C-c . i
if . then else
(setq ac-auto-start 0)
C-c . w
while . do done
C-c . b
begin . end
C-c . c
class = object(self) .inherit as super end;;
Sample .typerex file
C-x C-x
Switch between mark and cursor
# Sources are in ./src/
Edting
src
M-q / C-c C-q typerex-indent-phrase
# Use libraries $OCAMLLIB/unix and...
C-M-h
typerex-mark-phrase
I +unix /usr/local/lib/ocamlgraph
C-M-\
indent-region
C-x n d
typerex-narrow-to-phrase
# Do not include these files/units in the project
Refactoring
- src/example.ml test
C-o r
rename current ident
C-o t r
rename current toplevel module
Sample Makefile modification
C-o p
prune references in current module
# Call ocp-ocamlc instead of ocamlc
C-o q
eliminate current open, qualifying refs.
OCAMLC=ocp-ocamlc
C-o u
undo last multiple-file modification
© Copyright 2026 Paperzz