2

I'm looking for an atom package that generates C++ include guards in .h/.hpp header files. The package should do something like taking an existing C++ header file and surround its contents with appropriate #ifndef #define #endif lines.

If the plugin offers some additional features, like auto-generating cpp and h files from a given class name, that would be great, too.

I'm suprised I couldn't find a sensible plugin by googling for it. Are there any plugins around that match this description?

Note: This is not a question seeking for opinions (/out-of-topic), but for material to base my further research for such a plugin on.

Kalsan
  • 822
  • 1
  • 8
  • 19

1 Answers1

3

Create a snippet insted! Opent your .atom folders and in the snippets.cson file paste this snippet!:

'.source.js':
  'guards':
    'prefix': 'hd'
    'body': '#ifndef "${1:*}"\n#define "${1:*}"\n${2}\n#endif'
  'console.error':
    'prefix': 'error'
    'body': 'console.error(${1:"crash"});$2'

You will then type hd, press tab and start creating a safe header ;) You can change the prefix anytime by editing the snippet

Razvan Alex
  • 1,706
  • 2
  • 18
  • 21
  • 2
    There already is a snippet for that - using `def` prefix. It's bundled by default with `language-c` core package. – pamat Jan 16 '17 at 20:01