Read more about C++
Learn to define functions (perhaps static inline
ones) or macros, that is use wisely the preprocessor. Take inspiration from several of the many open source C++ projects on github or gitlab or elsewhere.
Regarding the choice of your C++ compiler and your source code editor, consider alternatives. Such as GCC or Clang for the C++ compiler, emacs for the editor, and perhaps ninja or make for your build automation. I also recommend using git as your version control.
I even recommend trying some Linux distribution (such as Ubuntu or Debian), since they are extremely developer friendly and contains a lot of examples of open source C++ code (in particular GCC or Clang or fish or FLTK). See also this.
How do you substitute multiple lines of cpp code?
A possibility is of course to generate some C++ code with another program (your own small C++ metaprogram, a Python script, a Guile one, etc...) then #include
that generated C++ file. Look inside RefPerSys for an example (work in progress). Or look inside Qt and its moc or ANTLR : they all generate C++ code.