Thread: Highlighting Braces...

  1. #1
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,273

    Highlighting Braces...

    Hi, I am using windows XP and the Microsoft Visual C++, and I was wondering if in that there is a way to highlight braces ... does anyone know how to do that with visual c++? it's no big deal really, it's just that I find it much easier to debug and whatnot for loops.

  2. #2
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    I don't think it will highlight them, but if you put the cursor on one then press Ctrl+']' the cursor will jump to the opening/closing one. Sometimes it messes up if there are braces enclosed in quotes. It works with parentheses and brackets too.

  3. #3
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,273
    thanks! that's just as good!!

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    If you get into the habit of typing such things in pairs, say
    Code:
    /**/
    for(;;){
      printf("");
    }
    Then you'll know the things are always going to be balanced before you do anything else.
    What's more, you can map out the overall structure of a function with just empty blocks like this, and it will compile.

    There's nothing worse than lots of crappy indented code with missing braces, closing comments or whatever.
    Code:
    void foo ( )
    {
         /* blah blah */
    for ( more blah )
    {
         /* lots of blah
    if ( some other blah )
       {
    }
    Sure you can add a brace or two, but was that if() really part of the for loop or not?
    And is it still part of the for loop when you've finished guessing where the braces go. Sure there are plenty of options when it comes to making the thing compile, but only one combination will make the code do what you want.

  5. #5
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Some text editors will highlight matching braces for you.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  6. #6
    Registered User
    Join Date
    Jul 2005
    Posts
    69
    I like this one Notepad++ . It will highlight your braces for you, syntax highlighting, ect... Just posting because I've found it multipurpose and quite useful.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. is curly braces here is a must?
    By mashour06 in forum C Programming
    Replies: 8
    Last Post: 04-25-2009, 04:41 PM
  2. error: braces around scalar initializer...
    By Osiris990 in forum C++ Programming
    Replies: 2
    Last Post: 02-27-2008, 03:22 PM
  3. [site suggestion] syntax highlighting hack/mod for BB
    By gibsosmat in forum A Brief History of Cprogramming.com
    Replies: 41
    Last Post: 11-17-2007, 05:16 PM
  4. What Do Braces Do?
    By jrahhali in forum C++ Programming
    Replies: 11
    Last Post: 04-18-2004, 04:14 PM
  5. Replies: 1
    Last Post: 12-01-2001, 08:17 AM