How can i write a function to do some specific operation on the line reddit / emacs ---------------------------------------------------------------------- anhsirk0 · 2022-02-14 18:34 what I want is to make a function to do this: class="btn btn-lg" -> class={`btn btn-lg`} basically replace the first `"` " -> {` and then second `"` " -> `} edit: fixed formatting ---------------------------------------------------------------------- Ok-Blacksmith4054 · 2022-02-14 20:58 Do a macro for it :) ---------------------------------------------------------------------- 7890yuiop · 2022-02-15 02:22 Unless this is something you're going to need long-term, I'd use a keyboard macro or a regexp search+replace. If you really want a function, give more details. Is this only for `class` attributes? What position (or range of positions) can point be at when you call the function? What if there are multiple such attributes on the line? ---------------------------------------------------------------------- anhsirk0 · 2022-02-15 07:14 this should work on only current line, regardless of class or any other attribute. ---------------------------------------------------------------------- anhsirk0 · 2022-02-15 07:15 how can i save a macro , so that i can use it over and over ? ---------------------------------------------------------------------- SlowValue · 2022-02-15 09:39 https://www.emacswiki.org/emacs/KeyboardMacrosTricks#h5o-5