Convert text strings in Todos or checkboxes in org-mode

I am trying to convert text strings in Todos or checkbox elements in org-mode. For example, if I have:

Line 1

Line 2

Line 3

I would like to convert this to

* TODO line 1

* TODO 2 line

* TODO 3 line

or

  • [] Line 1

  • [] Line 2

  • [] Line 3

I know that Cc - converts the selected area to a list ( source ):

  • Line 1

  • Line 2

  • Line 3

But is there a way to convert it to a checklist (or alternatively Todos strings?)

Thanks in advance!

+8
org-mode
source share
2 answers

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

upd: works with 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 (in) (beginning-of-line) (insert "- [ ] ") (forward-line)) (beginning-of-line))) 

So now, starting with:

 Line 1 Line 2 Line 3 

With C-3 Cc c you get:

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

Now with Cc C- * you can get:

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

upd: built-in way

Beginning with

 Line 1 Line 2 Line 3 

With Cx h Cu Cc - you will receive:

 - Line 1 - Line 2 - Line 3 

After Cx h Cu Cc Cx Cb you will receive:

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

But this is rather cumbersome, org-set-line-checkbox on top should be faster.

+8
source share

A very easy way to do this: following the instructions here :

"To do this in the region, use string-insert-rectangle. Set the label (C-) at the beginning of the first line you want the prefix to, move the cursor to the last line for the prefix and type Mx string-insert-rectangle. To do this for of the whole buffer, type Cx h Mx string-insert-rectangle. "

An example string can be used for the TO DO list: "* TODO"

Org mode understands this line as a TODO element.

0
source share

All Articles