Taha1506's blog

By Taha1506, history, 4 months ago, In English

Does anyone know how can I make a certain part of code always appear in Clion.And also how can I save a file as a template so that it appears without rewriting it?I searched the net but didn't see anything.

I got the solution to create templates Thanks to the comments.Now the only problem remaing is the following how can I make a part of code always appear when oppening a new file.More precisly I wan't this part always appear:

inclue <bits/stdc++.h>

using namespace std; int main(){ ios::sync_with_stido(false): cin.tie(nullptr);

return 0;

}

 
 
 
 
  • Vote: I like it
  • 0
  • Vote: I do not like it

»
4 months ago, # |
  Vote: I like it +3 Vote: I do not like it

Well, there exists something called Live Templates (another name for Snippets)

  • »
    »
    4 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Thanks a lot what if I want a part of code always appear without mention(include or return part?)

»
4 months ago, # |
  Vote: I like it +3 Vote: I do not like it

Go to settings or preferences (in Mac), then under the Editor section , you have Live Templates, select C/C++ and then click on '+'. Add your snippet with your abbreviation and a brief description (if u want). And you are done . Just use your abbreviation and CLion gives you the whole snippet.

  • »
    »
    4 months ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    Thanks.Do you have any idea on how to make a certain part of code always appear(in mean #include part ans similar things?

    • »
      »
      »
      4 months ago, # ^ |
        Vote: I like it +3 Vote: I do not like it

      Yes

      • »
        »
        »
        »
        4 months ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        So what is the idea?

        • »
          »
          »
          »
          »
          4 months ago, # ^ |
            Vote: I like it +3 Vote: I do not like it

          Like what do you want to achieve finally? You have your snippet and you want to use that as live template right ?

          • »
            »
            »
            »
            »
            »
            4 months ago, # ^ |
            Rev. 2   Vote: I like it 0 Vote: I do not like it

            Yes but in that way you have to write the abbrivation to make it appeare I want it to be there creating any new file.Without writing the abbrivation.

»
4 months ago, # |
  Vote: I like it 0 Vote: I do not like it

I think you mean "Creating" templates in Clion and I hope this may help you : https://www.jetbrains.com/help/clion/using-file-and-code-templates.html

»
4 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by Taha1506 (previous revision, new revision, compare).