Edit c autocomplete


#1

hello I am studying c and I would like to modify the form that atom autocomplete. for example, I do not use the variables of the main (I will do it in the near future), or I prefer to have the line jump at the beginning of the string and not at the end. thanks to whoever helps me


#2

The snippets? I believe if you write your own it will override the existing one. Alternatively, you can clone and link the language-c repo, but that may be overkill.

E.g., put this in your snippets.cson file (can get to it in menu bar, is in same folder as config.cson).

The body is the original, so edit it as you like. \n will make a new line, \t a tab (or equiv. in spaces if using soft tabs), ${n:foo} will make that part the nth selection (cycled with tab) and have default text foo.

'.source.c':
  'main()':
    'prefix': 'main'
    'body': 'int main(int argc, char const *argv[]) {\n\t${1:/* code */}\n\treturn 0;\n}'

#3

thank you very much. I managed to modify it to my liking. then I made one for printf. how can I make it to put \ n and not execute the line break? or where can you read about this? . thank you very much!


#4

A literal backslash should be \\. I can’t find a good up to date resource right now, but searching “JS string escape” will tell you more.


#6

a literal backslash is four backslash. i found this https://github.com/atom/language-c/blob/master/snippets/language-c.cson thanks for your help Aerijo