Does anybody know how to expand macros in visual c++ ?
For example.
#define FOR(i, n) for(i = 0; i < n; ++i)
It's faster to write FOR(i, n)
than for(i = 0; i < n; ++i)
, but for(i = 0; i < n; ++i)
is more
beautiful and comfortable, so I want to expand FOR(i, n)
pressing a button or buttons. Is there
any extension for visual c++ 2010 or 2012 ?
Thanks.
It's called code snippets, but I don't know how to use them in Visual C++. Try to google it.
I know about snippets, there is
for
snippet in visual c++ 2012, but when you select it, you must write i and n. It takes a little bit more time.http://www.youtube.com/watch?v=j5cSxC6pKnI 2:41 , this is what I want.
I don't know about vs, bit usually you can configure macroses and print some text including variables, that you can change. so you should add macro with only pain text
Yes it's possible, it can be done by creating a snippet, which prints plain text and then change the variables.
in Microsoft Visual studio Express 2012 write "for" and double tap the "TAB" button to automatically insert the for loop body for (int i = 0; i < length; i++) {
it is like the above after that you can change the "length" with anything you want
If you get used to the long version, it will be faster to write than short.
I think that the time spent typing in the solution is negligible altogether in comparison to the time spent reading, thinking, testing and debugging. Also, most people here are fast typists anyway. Thus, in my opinion, shorthand macros like
FOR
succeed only in making the code less readable, which leads to harder debugging.