Creating Reusable Keyboard Macros In Emacs
There is a concise article on how to use keyboard macros in Emacs that I recommend you read. The info in that article can be adapted to solve your specific problem like this:
- Place your cursor on the 'F' in a variable declaration of type
- Hit C-x ( to start recording a macro.
- Type s t d : : s h a r e d _ p t r < C-right >
- Hit C-x ) to stop recording the macro.
- Hit M-x name-last-kbd-macro to give the macro you just created a name. For this example, I called it
- Open your emacs configuration file.
- Type M-x insert-kbd-macro and tell it to insert
std-shared-ptr. The end result should look like this.
(kmacro-lambda-form [?s ?t ?d ?: ?: ?s ?h ?a ?r ?e ?d ?_ ?p ?t ?r ?< C-right ?>] 0 "%d"))
fset function creates an interactive function named
std-shared-ptr, and you can see what keys are going to be sent to Emacs by inspecting the vector it generated.
You can invoke this macro by hitting M-x std-shared-ptr, but if you're going to do this a lot, you might want to bind this to something that's easier to type. Also, we created this macro using
Foo, but the C-right we hit while creating the macro should make it work for any type or class.