Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Force Qt Creator to use a syntax highlighting for a file
Forum Updated to NodeBB v4.3 + New Features

Force Qt Creator to use a syntax highlighting for a file

Scheduled Pinned Locked Moved Qt Creator and other tools
9 Posts 5 Posters 18.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • X Offline
    X Offline
    xgbi
    wrote on last edited by
    #1

    Hey guys,

    In my project I use some "non-standard" file extension, like ".ccp", in which the code is C++.

    Problem is: when editing them in QtCreator, I don't get the syntax highlighting, which forces me to use an editor that gives the choice for syntax highlighting.

    Do you know if I can force an opened file to be interpreted in C++ (or whatever syntax I choose to use)?

    I tried some manipulations with kate syntax highlight, but it doesn't seem to work.

    Any idea?

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      Hi xgbi
      which version of qtcreator did you use? A new version 2.2 was just released. It has some added high-lighting features, but those seem to be limited special new features.
      "qt creator release note":http://labs.qt.nokia.com/2011/05/06/qt-creator-2-2-released/

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • T Offline
        T Offline
        tobias.hunger
        wrote on last edited by
        #3

        ... and you can finally configure MIME types in Qt Creator 2.2, too. So go to Tools->Options->Environment->MIME Types and add your extensions as needed and Qt Creator will treat those just like the built-in ones.

        1 Reply Last reply
        0
        • X Offline
          X Offline
          xgbi
          wrote on last edited by
          #4

          That did the trick!

          Thanks!

          1 Reply Last reply
          0
          • K Offline
            K Offline
            koahnig
            wrote on last edited by
            #5

            Thanks for the hint Tobias. That is exactly what I was looking for.

            Vote the answer(s) that helped you to solve your issue(s)

            1 Reply Last reply
            0
            • N Offline
              N Offline
              Nice
              wrote on last edited by
              #6

              I tried changing the filter for syntax highlighting for text/x-csrc to match .cl files as well. These are files containing OpenCL code, which look similar to C code but still differs a bit in syntax, hence I will get a lot of underlined code as well. Is there some way to prevent the editor to underline text in red, only for .cl files?

              1 Reply Last reply
              0
              • T Offline
                T Offline
                tobias.hunger
                wrote on last edited by
                #7

                Nice: Please do not necro-post and open a new thread for your issue.

                Go to Tools->Options->Text Editor->Generic Highlighter and download more highlight definitions. There is one for OpenCL in the list which should get you basic highlighting, even though there is of course no code model support for that.

                I usually just grab the complete set of highlighter definitions:-)

                1 Reply Last reply
                0
                • N Offline
                  N Offline
                  Nice
                  wrote on last edited by
                  #8

                  Thanks, it worked! Although it didn't work the first time when I pressed OK (I still got a message saying that no syntax highlighting was found for the file type), and I had to open up the options again and press Apply.

                  Why is it not good to ask a question in an already existing post? I figured that if anyone else has the same question as I, they will probably find this thread too when googling for an answer, and now they will find the answer in this post instead of also having to open a new thread...

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    Hi,

                    It's because of time: the original post is 3 years old and you're question is related but not the same so it deserves its own thread :)

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved