Visual studio feature - commenting code Ctrl K - Ctrl C
Posted
by Michael
on Stack Overflow
See other posts from Stack Overflow
or by Michael
Published on 2010-05-23T10:24:10Z
Indexed on
2010/05/23
10:30 UTC
Read the original article
Hit count: 285
visual-studio
|hidden-features
I commented on this answer some time ago regarding how visual studio comments out code with //
or /* */
. I was thinking to revise the answer (to include my findings) but I had to test it first, which kind of confused me.
My finding is that depending on where your marker is when you press Ctrl - K, Ctrl - C you will get either //
or /* */
. So I tried it out on the following code:
[1] [2]FD_ZERO(&mFSet);
FD_SET(user->mSender, &mFSet);
timeval zeroTime = { 0, 0 };
int sel = select(0, NULL, &mFSet, NULL, &zeroTime); [3]
if (sel == SOCKET_ERROR){
[5]return false; [4]
}
if (sel == 0){ [6]
return false; [7]
}
The [x] is markerpositions. All [1] positions give //
for all marked lines. However
- Start position > End Position: gives:
- [2] > [3] :
/* */
- [2] > [4] :
//
- [2] > [5] :
/* */
- [2] > [more than 5] :
//
- [5] > [6] :
/* */
- [5] > [7] :
//
I guess it has to do with forward indentation (not backwards), that whenever code is indented more than the starting line you get //
except when you haven't selected any text on the indented line ([2] > [5]).
But why the distinction? Why not use /* */
for when you start at [2] and //
when you start at [1]?
© Stack Overflow or respective owner