Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

org-mode

I'm trying to convert lines of text into Todos or check box items in org-mode. For example, if I have:

Line 1

Line 2

Line 3

I would like to convert that to either

*TODO Line 1

*TODO Line 2

*TODO Line 3

or

  • [ ] Line 1

  • [ ] Line 2

  • [ ] Line 3

I know that C-c - will convert the selected area into a list (source):

  • Line 1

  • Line 2

  • Line 3

But is there any way to convert it into a list with check boxes (or alternatively, lines of Todos?)

Thanks in advance!

like image 856
krishnan Avatar asked Sep 06 '13 22:09

krishnan


2 Answers

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

like image 66
sanimalp Avatar answered Sep 28 '22 05:09

sanimalp


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.

like image 27
abo-abo Avatar answered Sep 28 '22 04:09

abo-abo