20

How do I exclude directories from being indexed in CLion?

I have several GB of data being indexed that are slowing everything down.

In PyCharm I can just right-click on the directory, but I don't find this option on CLion.

To be more concrete, I have a project with the following structure:

release/
release/results
source/
build/

the directory release/results contains several GB of data. CMakeList.txt only contains the list of files inside source/, however, the indexer is indexing the files inside release/results.

Jorge Leitao
  • 19,085
  • 19
  • 85
  • 121

3 Answers3

15

As of CLion 1.5 (EAP for now), you can mark directories as either 'source', 'libraries' or 'excluded'.

See the full blog post describing the new feature:

Although CLion automatically excludes build directories from indexing, some users expect wider options. The same situation can happen when some folders are too big or located on network storage, making their indexing too expensive. To let CLion know that this is the case, you may want to manually exclude folders from indexing.

etienne
  • 3,146
  • 1
  • 24
  • 45
  • You beat me a few hours to answer that CLion 1.5 EAP finally supports directory exclusion! :-) – marco.m Dec 18 '15 at 09:54
  • :D this question was the first thing that came to my mind when i read the release notes! – etienne Dec 18 '15 at 13:31
  • I'm still not seeing this option in CLion 2019.2 for non-CMake projects. I had to open my project in PyCharm and mark the directory as excluded there. This immediately caused the directory in CLion to become excluded as well (it even turns red). I believe this works because all JetBrains editors are able to read/modify/watch the same underlying XML files. – Alex Jansen Sep 30 '19 at 19:02
  • I wasn't able to do this in CLion 2020.3, but https://stackoverflow.com/a/60474140/353178 worked great! – mkirk Dec 15 '20 at 16:35
  • Worked for me with CLion 2021.3.3 only after I removed `.idea/modules.xml` and `*.iml` files. – KindDragon Feb 14 '22 at 16:54
8

Excluding a whole directory isn't possible, however you can exclude files by file type.

Preferences | Editor | File types

enter image description here

Beware that these settings aren't persisted after updating CLion to a newer version (at least this was the case for me when updating from 1.05 to 1.1).

nburk
  • 22,409
  • 18
  • 87
  • 132
  • 2
    PyCharm is better in this regard, and I hope the feature is added. Meanwhile, your answer solved my problem. Thanks! – Jorge Leitao Aug 21 '15 at 23:10
  • 2
    I have CLion EAP build on 28 October 2015. It seems this dialog allows to exclude directories too. But there is still no "Mark as excluded" context menu for project items. – Dzenly Nov 19 '15 at 08:29
  • 2
    Note that starting from 2015-12-17, CLion 1.5 EAP supports excluding directories. See etienne answer. – marco.m Dec 18 '15 at 09:57
  • 1
    Brilliant! This applies to my version of this question -- how do you tell CLion to ignore a particular file or file type. It was adding a step to the function rename wizard every time. – CivFan Jul 23 '18 at 17:47
  • This only appears to work for CMake projects. If you're just using CLion as an editor then there's no exclude option and everything still gets indexed for searches. – Alex Jansen Jun 29 '19 at 01:54
6

It's possible! It would help if you changed in .idea/YourProject.iml content block:

 <content url="file://$MODULE_DIR$">
      <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
      <excludeFolder url="file://$MODULE_DIR$/public/bundles" />
      <excludeFolder url="file://$MODULE_DIR$/node_modules" />
    </content>

warning: You should write your excludeFolder lines

Is the solution not in any documentation in jetbrance, but employer from this company suggested this solution =)

webdesus
  • 357
  • 4
  • 6