Search code examples
pycharm

Search for variable name in Pycharm without getting variables containing the same string


I am trying to debug some code in which a variable a is getting an unexpected value. unfortunately there are also variables 1_a and a_2 and between the 3 searching for variable a using pycharm's cntrl+f search yields over 100 results does anyone know of a way to limit the search to just variable a? Thanks.

Note: The original programmer isn't quite so evil as to have named variables a_1 and 2_a. While he had names some functions in camel case and some classes in snake case (which gave me a few head scratchers) I have been asked not to give any details on the program so I'm using variable names which replicate the problem. While this is probably overly cautious it replicates the problem perfectly and I'd rather be safe than sorry.


Solution

  • You just need to toggle full word (or exact match) search. In the search bar (that opens at the top after pressing ctrl+F), press the enter image description here button (or alt+W).

    Without:

    Picture showing all search results, without using exact match

    With:

    enter image description here