Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TODO comments in rStudio

is there a way to list ToDo comments in rstudio?
Before I used eclipse and really loved to put some # TODO I definitely need more unit tests here! comments in my source code.

I could not find this feature in rStudio so far and I was wondering, if there is something like a plugin or maybe an easy way of searching such comments.

like image 567
drmariod Avatar asked Aug 07 '15 09:08

drmariod


People also ask

How do you write comments on todo?

TODO comments are just code comments that start with a single string of capital letters like // TODO or // FIXME. Most of the TODO comments in your code are probably sitting unattended and forgotten in your team or organization's source code.

How do you use Todo comments?

To create a TODO commentPlace the caret where you want to create a TODO item and add a comment, for example, by pressing Ctrl+/ , then type TODO or FIXME , and then type your note.

What is the purpose of adding todo in a comment?

In general, a TODO is written to tell future maintainers about something important: something that should be added, or should be changed, or should not be forgotten. The intention is often to increase the quality of the code. Sometimes a TODO comment can save you a lot of time!

How do I comment Todo in Intellij?

In the Settings/Preferences dialog ( Ctrl+Alt+S ), select Editor | TODO. Use a regular expression to specify a custom pattern. This matches the word "optimize" ( \b designates word boundaries) and allows any number of other characters in the comment. Then click OK to save the new pattern.


4 Answers

I would suggest that you consider the todor RStudio add-in by dokato. After installing via devtools:

devtools::install_github("dokato/todor")

You will be able to conveniently list ToDo items across your project:

sourcing

Official example

(images and code sourced from: https://github.com/dokato/todor)

like image 183
Konrad Avatar answered Oct 01 '22 16:10

Konrad


There is no such system in RStudio, but there is an easy way of searching for the comments. Do this:

  1. Go to Edit -> Find in Files
  2. Tick the checkbox "Regular Expression"
  3. Enter the following regular expression: ^\s*# TODO
  4. Click Find

That regular expression will match any line that starts with # TODO.

like image 33
Jonathan Avatar answered Oct 04 '22 16:10

Jonathan


You can use the outline list by having:

# TODO I definitely need more unit tests here! ####

Just keep in mind that you have to have 4 '#' at the end of the line

like image 30
Fabian Avatar answered Oct 03 '22 16:10

Fabian


If you work with git and the files are tracked you can use

git grep TODO

in the terminal (which is also included in the Rstudio IDE) to get a list of your TODOs.

like image 31
andschar Avatar answered Oct 05 '22 16:10

andschar