Tips & Tricks

CLion Editor Basics — Schemes, Themes and More

Like other members of the IntelliJ IDEA family of products, CLion provides its users with plenty of options for customizing their editing experience. In this post we’ll take a look at some of the ways you can tune CLion to look and behave the way you prefer, as well as some of the UI features and how they affect your coding experience.

Color Schemes

Color schemes define how your code looks when being edited. The kinds of things you can configure in CLion include:

  • The font that’s being used to render code; this includes the typeface as well as bold/italic styling
  • The foreground and background colors for each of the code elements
  • The color of the stripe marks that indicate errors, warnings etc. in the margin

CLion comes with a set of pre-existing color schemes (e.g., Darcula), but if you need to customize some setting on a built-in scheme, you should save it under a new name using the Save As… button.

UI Themes

Unlike the schemes setting, the theme setting controls the appearance of the user interface around the code. This affects all aspects of CLion’s UI, including the menu, tool/navigation bars, tool windows, and just about everything else except the code editor.

As with schemes, CLion provides a setting to choose a predefined theme:

Out of all the themes, the one of particular note is, of course, Darcula, which is a dark theme. Darcula comes with a matching color scheme, completing the ‘dark UI’ user experience:

Code Style Settings

Next up we have the options for tuning CLion to your own coding style. These settings can be tuned for each project individually. The kinds of things covered include per-language settings for:

  • Tabs and indentation (how big the tabs are, whether to use tabs or spaces, how to indent lambdas, etc.).
  • Spaces — this gives rather detailed options for whether to put spaces before parentheses, around operators, before the left brace, and so on. Each of the options is customizable depending on the type of code element you are working with.
  • Wrapping and Braces — these settings determine the rules for how structures are aligned and where braces are placed.
  • Blank Lines — just as the name suggest, these settings determine where to place blank lines to visually separate different types of code elements.
  • Code Generation — this setting controls prefixes and suffixes for generated code elements, and also lets you define the top-level declaration order.

For the settings where code is affected, CLion gives you an immediate preview of your changes in an editor box right next to the code style options, with the recent change in a setting being used to highlight affected lines:

Sharing Settings

CLion provides a way of exporting (i.e., saving) your settings to a file, so that you can share your settings with other people. To save your settings, choose File | Export Settings and pick which settings you want to export. There are lots of options here – you can export style settings, live templates, plugin-related settings and much more.

All the settings you export get packed into one .JAR file that you can subsequently share. Anyone wishing to import these settings can simply choose File | Import Settings from the menu and that’s it – the settings will be loaded!

Code Folding

Folding is a feature that lets you collapse large code blocks to a single line. The purpose is, of course, readability of large files. Folding happens on particular scopes: for example, you can fold a function or an entire class definition.

To fold a code block, simply click the minus (-) sign on the chevrons in the margin just to the left of the code:

Note that the chevrons are very faint so as to not distract you from typing. A folded code block shows a plus (+) icon on the chevron instead, which can be clicked to expand the selected block.

Another thing worth noting is that some elements, such as template parameter blocks or large groups of #include statements appear folded by default. To view them, you can either unfold them or, alternatively, hover the mouse over them to see the expanded content:

Tool Windows

In addition to the main editor windows, CLion also has plenty of tool windows that pop up on the sides of the main window. Many of them are folded too, which means you’d have to click them to bring them up!

All of the tool windows serve a different purpose: some show up by necessity (e.g., at compile time), but others are more vocational. For example, the CMake window has a cache editor:

Also, one of the tool windows is a fully-fledged terminal, letting you do things on the command line from within the comfort and safety of the IDE (and before you ask, yes, it does have history cycling and on-Tab completion):

Watch this in action:

So, these are some of the basic features of the CLion editor. If you haven’t seen CLion already, grab the EAP build and give it a go! ■

Comments below can no longer be edited.

11 Responses to CLion Editor Basics — Schemes, Themes and More

  1. Avatar says:

    February 21, 2015

    I noticed that the C/C++ file templates are still not working. Is that just me, or hasn’t this been addressed yet? Wil they be fixed in the final release?

    • Anastasia Kazakova

      Anastasia Kazakova says:

      February 23, 2015

      It’s not done yet. It will come to 1.0 release.

      • Avatar

        Jennifer Kuiper says:

        February 23, 2015

        Gr8! Can’t wait

  2. Avatar

    Idontknow says:

    February 22, 2015

    Themes, schemes.. and makefile integration is still waiting.
    You are creating IDE for Linux and C – makefile integration is freaking important if you want to ever beat Vim/Emacs (yes, I know) or sublimetext.
    If you want to make this integration in a perfect way (so you need a lot of time) please just tell us this..

    • Anastasia Kazakova

      Anastasia Kazakova says:

      February 23, 2015

      Sorry, but we are not planning the Makefiles support before the 1.0 release. We’ve selected CMake as a first build system to support (here are some reasons for that – Others will come later, you can follow the feature request in our tracker to get the updates on this –

      • Avatar

        Lucas Holt says:

        March 10, 2015

        After reading this blog post, I think it makes sense. When you start getting into make, you have to consider all the different versions. Sure, Linux and Mac users will tend to use GNU Make. Windows users will use the make that comes with Visual Studio, and users on other platforms such as FreeBSD, MidnightBSD, NetBSD, Solaris, etc. will use their platforms preferred make (not GNU).

        I don’t care so much about building from the IDE, but rather that I have decent syntax highlighting and ability to jump to code much easier. I write a lot of open source software in C on BSD systems and would love to use this tool for that.

        • Avatar

          Michael Hewitt says:

          March 4, 2017

          After complaining about the lack of Makefile support, we converted all of our Makefiles over to CMake, and life is *much* better. We did this for reasons other than just CLion support – it eliminated many problems we were having with our overgrown Makefiles that had evolved over many years. And, we had no problem implementing the custom script portions of our Makefile, as well as calling out to Makefiles for legacy code that we are importing. This may not be an option for everyone, but it makes sense for CLion to consume CMake files because they are declarative and make the project structure natural for an IDE to import.

  3. Avatar

    Rinaldi says:

    February 22, 2016

    Does anyone had ever the patience to copy the Visual Studio Theme into Clion? I’d like it very much.

    • Avatar

      t0b4cc0 says:

      April 14, 2016

      id love this too

  4. Avatar

    chris says:

    March 21, 2017

    In Clion, I frequently use “// ToDo:” just so that I have a highlighted comment line. Is it possible to (or maybe it already exists) to have something like highlighted comments…

    For instance, “// /r correct this” “// /b Input File Read-In” “// /g Alg start” etc. where each comment line is colored according to the highlight…

    Then, with a flag in the top line of the doc, I can add or delete “// /h” or “// /highlight” when I push my code or something.

    • Anastasia Kazakova

      Anastasia Kazakova says:

      March 21, 2017

      Hm. These TOFO/FIXME patterns are configurable under File | Settings | Editor | TODO. So you can add your custom ones.
      But there is no option with a flag.

Discover more