I need to replace guid_here by different uuid.

provider [guid_here]
[guid_here] provider
test again [guid_here]
test again2 [guid_here]
test [guid_here] again2 

I use this approach.

Install package "uuid" - UUID

I need create uuid exactly in the cursor place. To do this I create custom function:

  (defun uuid-insert()
      (require 'uuid)
      (insert (upcase (uuid-string))))

and bind to key:

(global-set-key (kbd "C-c C-'") 'uuid-insert)

Also I need package multiple-cursor multiple-cursor

and here steps.

  1. Select guid_here

enter image description here

  1. Use mc/mark-all-like-this

enter image description here

  1. Press Del

enter image description here

  1. Use my custom function uuid-string to insert uuid in every line. I must use keybinding for this - C-c C-' . If use by function name uuid-string it's not work.

enter image description here

As you can see, now in every line has different uuid. Nice.

It's very cool.

Is it best approach to generate uuid in every lines?


1 Answer 1


The way I'd do this is with search and replace. You can call Lisp code from a regexp replacement with \,(my-function …). So call M-x replace-regexp (or C-M-% which is bound to query-replace-regexp by default). Use \[guid_here] as the regexp to search for and [\,(upcase (uuid-string))] as the replacement text.

  • 1
    Emacs is very cool :-) Commented Jun 5, 2019 at 12:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.