Exclude directories from indexing in CLion
Asked Answered
C

3

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.

Chape answered 15/4, 2015 at 14:11 Comment(4)
clion indexes files defined as 'sources' in CMakeLists.txt (+ headers included from the source files)Sulfide
@etienne, are you sure about that? I have just updated the question with more details.Chape
In my projects, directories under the root containing no source files (from CMakeLists.txt) are greyed out; is it the case for you ?Sulfide
@etienne, yes, but when the directory is full of data, CLion still tries to index it.Chape
S
16

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.

Sulfide answered 17/12, 2015 at 14:20 Comment(5)
You beat me a few hours to answer that CLion 1.5 EAP finally supports directory exclusion! :-)Insured
:D this question was the first thing that came to my mind when i read the release notes!Sulfide
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.Phrixus
I wasn't able to do this in CLion 2020.3, but https://mcmap.net/q/619505/-exclude-directories-from-indexing-in-clion worked great!Nimiety
Worked for me with CLion 2021.3.3 only after I removed .idea/modules.xml and *.iml files.Heretofore
H
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).

Hustings answered 19/8, 2015 at 5:18 Comment(5)
PyCharm is better in this regard, and I hope the feature is added. Meanwhile, your answer solved my problem. Thanks!Chape
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.Johannejohannes
Note that starting from 2015-12-17, CLion 1.5 EAP supports excluding directories. See etienne answer.Insured
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.Hofstetter
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.Phrixus
E
7

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 =)

Escudo answered 1/3, 2020 at 10:28 Comment(2)
Checked in 2019.3 versionEscudo
Also works in CLion 2022.3Suffruticose

© 2022 - 2024 — McMap. All rights reserved.