Suppose I have this text, where | is point.

This is the te|xt.

Now I want to put the word text in bold, so I use Org keybindings and do C-c C-x C-f and pick *. This is what happens:

This is the te *|* xt.

Would it be possible to have the markers surround the symbol where point is? Like this:

This is the *text*|.

I know org-emphasize works on the active region, but it would be quicker if it was done automatically on the symbol where point is.


You just need a function that marks the current word when the region isn't already active:

(defun org-emphasize-dwim (&optional char)
  (unless (region-active-p)
  (org-emphasize char))

You can rebind the keys to call this instead of the normal org-emphasize:

(define-key org-mode-map [remap org-emphasize] #'org-emphasize-dwim)

I use something like this:

(defun bold-region-or-point ()
  (if (region-active-p)
        (goto-char (region-end))
        (insert "*")
        (goto-char (region-beginning))
        (insert "*"))
    (insert "**")

and bind it to a convenient key like:

(define-key global-map (kbd "s-b") 'bold-region-or-point)
  • Could this solution be modified so it could apply the *s on the beginning and end of lines in that active region as well?
    – SFbay007
    Sep 17 '17 at 22:18

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.