Convert lines of text into Todos or Check boxes in org-mode

You can use this function to make the current line(s) into checkbox(es):

upd: works on regions too

(defun org-set-line-checkbox (arg)
  (interactive "P")
  (let ((n (or arg 1)))
    (when (region-active-p)
      (setq n (count-lines (region-beginning)
                           (region-end)))
      (goto-char (region-beginning)))
    (dotimes (i n)
      (beginning-of-line)
      (insert "- [ ] ")
      (forward-line))
    (beginning-of-line)))

So now, starting with:

Line 1
Line 2
Line 3

With C-3 C-c c you get:

- [ ] Line 1
- [ ] Line 2
- [ ] Line 3

Now with C-c C-* you can get:

* TODO Line 1
* TODO Line 2
* TODO Line 3

upd: the built-in way

Starting with

Line 1
Line 2
Line 3

With C-x h C-u C-c - you get:

- Line 1
- Line 2
- Line 3

After, with C-x h C-u C-c C-x C-b you get:

- [ ] Line 1
- [ ] Line 2
- [ ] Line 3

But this is rather unwieldy, org-set-line-checkbox from above should be faster.


A very simple way to do this is by following the instructions here:

"To do this to a region, use string-insert-rectangle. Set the mark (C-) at the beginning of the first line you want to prefix, move the cursor to last line to be prefixed, and type M-x string-insert-rectangle . To do this for the whole buffer, type C-x h M-x string-insert-rectangle ."

Example of string could be used for your TO DO list: "* TODO "

Org Mode understands this string as a TODO item.


I highlight the region and then do C-c - and then re-highlight and do C-u C-c C-x C-b.

Tags:

Org Mode