Your web-browser is very outdated, and as such, this website may not display properly. Please consider upgrading to a modern, faster and more secure browser. Click here to do so.
Keyboard macros can be crazy helpful in emacs, and allow you to automate repetitive processes you come across when coding. if you have a sequence of keystrokes you use day-to-day, here is how to convert them to a function and bind it to a key:
C-x (to start your macro
C-x )to end the macro
C-x C-k nto call
kmacro-name-last-macroand assign a name to your macro
M-x insert-kbd-macroto output the lisp code of your new macro
(global-set-key <key> '<macro_name>)to bind it to a key. C-x C-k 0-9/a-z are reserved for personal key bindings. you can also use the f1 - f12 keys
and your done! now you have compressed several keystrokes into just one, and it’ll also be there when you need it.
Emacs is a wonderful, powerful text editor, but it can take some getting used to. Here are some of the commands you need to know to go from n00b to a text-editing ninja:
Taken from my answer to this question
Key: C = Ctrl, M = Esc. (Protip: if you are a heavy emacs user, switch your caps lock key to an esc key to make the commands a lot easier)
Basic Text Editing C-space: set mark C-w : Cut M-w : Copy C-y : Paste C-x s : save C-x c : save all and close
Navigating Through a File
M-b : back one word M-f : foward one word C-f : forward one character C-b: backward one character C-a : beginning of line C-e : end of line C-n : next line C-p : previous line M-< : beginning of buffer M-> : end of buffer
Using Multiple Files
C-x C-f : find file C-x b : switch buffer C-x k : kill buffer C-x 2 : split-window-vertically C-x 3 : split-window-horizontally C-x o : switch window C-x 0 : kill this window C-x 1 : kill all other windows
Other Handy Commands
C-s : search C-r : search backward M-/ : autocomplete word (based on previous words in the file) C-x ( : start keyboard macro C-x ) : end keyboard macro C-x e: execute keyboard macro.
C-h: help C-h f: describe function C-h k:describe key
but this is just scratching the surface. If you have any other questions about using emacs, feel free to ask!