nernac
nernac

Reputation: 185

Why is Pycharm not highlighting TODO's?

In my settings, I have the TODO bound to highlight in yellow, yet in the actual code it does not highlight. Here is a screenshot of my settings: Editor -> TODO

Does anyone know how to fix this?

EDIT: I even tried re-installing Pycharm and I still have the issue.

EDIT 2: In the TODO Window, it is saying "0 TODO items found in 0 files". I believe this means it is looking in the wrong files to check for TODO items. However, when I try to find TODO items in "this file" it still doesn't work. Does anyone know why this is?

Upvotes: 9

Views: 5498

Answers (6)

Ramon
Ramon

Reputation: 97

Try this (not the upper case B):

\bTODO:\B.*
\bFUTURE:\B.*

If you type your TODOs like me, with a colon after the word, then \bTODO:\b does not work (anymore?) in PyCharm. To match the space after the colon you need the upper case \B instead of \b.

Ref: Difference between \b and \B in regex

Upvotes: 0

Crowell
Crowell

Reputation: 35

It might be the file type. Right click, Override File Type.

I had this issue with a text file and it's copy, only the first one would use #TODO

Upvotes: 0

Caroline
Caroline

Reputation: 21

I had the exact same problem, and the solution suggested by theBrownCoder worked perfectly.

For those who cannot find which menu theBrownCoder is referring to, go to File > Settings > Project: "Title of Project" > Project Structure.

It is in the dropdown of Project in Settings where you can also select your Python interpreter.

Upvotes: 0

dullday
dullday

Reputation: 111

I think the problem for me was the same as explained by @theBrownCoder but I couldn't find the project structure settings.

Apart from not showing TODO's another symptom was impossibility to go to function definitions defined in other files and inability to rename python files with the error: "Selected element is used from non-project files. These usages won't be renamed."

Googling for this the solution that worked for me was to delete the .idea folder (make sure to back it up just in case, you will lose the configurations).

Upvotes: 1

theBrownCoder
theBrownCoder

Reputation: 106

Go to Preferences (or Settings), Project Structure, and make sure the folder with your files is not in the "Excluded" tab's list.

Click the folder you want to include and click on the "Sources" tab. Click Apply, then OK!

It should work.

Upvotes: 9

nicorellius
nicorellius

Reputation: 4043

I recently updated PyCharm Professional and my TODOs no longer worked. I went into settings and changed the alert icon, then saved, and retyped them and they worked. I imagine for my case, there was a delay in the new version picking them up. Might just need to retype them to get them working again, though the reboot should have addressed this.

Not sure if your pattern is causing this, but mine is set up like so, with two separate patterns:

\btodo\b.*
\bfixme\b.*

Neither is case sensitive, BTW...

Perhaps try some other patterns to see if you can get those to work.

Upvotes: 2

Related Questions