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: 279

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

Related posts about visual-studio

Related posts about hidden-features

  • Hidden features of MySQL

    as seen on Server Fault - Search for 'Server Fault'
    In the long tradition of having hidden features, let us have a list of hidden features in MySQL. Do put one feature per answer. Also See: Hidden Features of Linux Hidden Features of PowerShell Hidden features of Oracle Database Hidden Features of Windows 2008 Hidden Features of Solaris/OpenSolaris Hidden… >>> More

  • Hidden features of Bash

    as seen on Stack Overflow - Search for 'Stack Overflow'
    Shell scripts are often used as glue, for automation and simple one-off tasks. What are some of your favorite "hidden" features of the Bash shell/scripting language? One feature per answer Give an example and short description of the feature, not just a link to documentation Label the feature using… >>> More

  • Hidden features of classic asp

    as seen on Stack Overflow - Search for 'Stack Overflow'
    I am still a fan of Classic ASP and know a lot of developers still using classic ASP, although by far there are very few features available in ASP, let us list out the most useful and not so well known ones Of course the question is on the lines of the Hidden Features questions listed below.: Hidden… >>> More

  • Hidden features of Python

    as seen on Stack Overflow - Search for 'Stack Overflow'
    What are the lesser-known but useful features of the Python programming language? Try to limit answers to Python core One feature per answer Give an example and short description of the feature, not just a link to documentation Label the feature using bold title as the first line This question… >>> More

  • Hidden Features of MXML

    as seen on Stack Overflow - Search for 'Stack Overflow'
    What are some of the hidden features of MXML? MXML being used in Flex Framework became quite popular language (because Flash Player is something every PC has and Flash Builder, Flash Catalist are quite popular Adobe programms) So at least from the existing features, do you know any that are not… >>> More