3

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.

2 Answers 2

2

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

(defun org-emphasize-dwim (&optional char) (interactive) (unless (region-active-p) (backward-word) (mark-word)) (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) 
0
3

I use something like this:

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

and bind it to a convenient key like:

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.