2

I use double brackets heavily for links. Is there anyway to config smart autocompletion such that pressing brackets twice I get [[] instead of [[]], and once the prompt is at left of ] in [[], pressing ] again close the link, that is, produces the final [[]]?

4

My first thought is use org: C-c C-l, and type your link, with optional description.

Second thought, write a function like:

(defun my-link (s)
 (interactive "sLink: ")
 (insert (format "[[%s]" s)))

and bind it to some key if you like.

Third thought: look into yasnippet or skeleton.

  • That works. I am currently using a yasnippet to trigger that (simply [[$1][$2]$0, triggered by "link"). It always work. But for some reason that I don't quite understand, the emacs running in ubuntu do what I described in the question, on mac it doesn't. – Diogo Mar 2 '16 at 23:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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