Are there any good C++ support for Atom?


#1

The Atom’s C++ package support

is not very great. For example if I type this

int main()

As soon as I getting a suggestion to add the main function this is what I get

int int main(int argc, char const argv[]) {
/
code */
return 0;
}

See how it repeats int twice and how it adds “int argc, char const *argv[]” when I did not want this to be added.

On top of that it uses the egyption style braces rather than this style
{
// Code
}

Is there something where I can tweak the settings or do you guys know a better extension/package that does a better job. Something like Visual Studio IDE can do?


#2

This is a snippet, and is defined here. You need to differentiate what you’re doing from what Atom’s doing. It’s not repeating int twice. You typed int once, and then when you used the snippet, Atom expanded main into int main(int argc, char const argv[]) etc. If you want to continue using that particular snippet, just stop typing int. You can also override that snippet, by adding your own to snippets.cson. By adding a custom snippet with the same key (the second line of this code block), you override the one from the language package.

'.source.c, .source.cpp, .source.objc, .source.objcpp':
  'main()':
    prefix: 'main'
    body: 'main()\n{\n\t${1:/* code */}\n\treturn 0;\n}'

#3

@DamnedScholar How do I override the snippets.cson?


#4

snippets.cson is your file. You use it to override other snippet files.


#5

Take a look at this, when I opened snippets I don;t see anything in it :confused:


#6

Because you haven’t added anything. You need to take the code I posted above and paste it into that file.


#7

Oh ok thanks @DamnedScholar :slight_smile:


#8

@DamnedScholar One thing, with the snippets code that you have provided, does it override everything, or only the stuff that you specified?


Language-C package snippits
#9

It overrides the snippet named 'main()' in the scopes .source.c, .source.cpp, .source.objc, and .source.objcpp.


#10

Oh ok thanks for your help :slight_smile: