Looking for this for years. I am going to be brave and ask.

(defun paste-hello-world ()
    (paste-raw-text-at-cursor "hello world\n")

Need something like the above. The place I work at has custom headers for their code, so I want write some shortcut to generate them.

Alternatively, is a way I way I can pipe bash output from a bash command to my active buffers cursor?

Googling this as very challenging, as most results just tell you how to copy-and-paste text using Emacs. Some hints on the jargon for googling this would also be appreciated,

  • 2
    Use function insert. But first read some of the manual (C-h i) Emacs Lisp Intro, to at least find out how to invoke a function in Elisp.
    – Drew
    Commented Mar 7, 2023 at 22:19

1 Answer 1


As suggested insert should serve you for a few "shortcuts". Since it sounds like you want to auto-insert boilerplate you'll probably want something more powerful. The Emacs wiki has some options. Emacs comes with an auto-insert-mode. The package lice.el provides header templates for common licenses, and allows you to define your own custom file headers. A more powerful option would be a snippet framework like yasnippet (which you could combine with auto-insert-mode). You could also look at Insert boilerplate automatically when a new file is created, Inserting/updating source file header comments and Template for new file.

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