Visual Studio 2010: Navigate feature (Symbols search)

 

Those who used Visual Assist with Visual studio has experienced one of the powerful features, called Symbol Navigation (this is not the debug symbols). i.e we can search for functions, variables, classes etc. in the workspace very easily. Those who haven’t tried it yet, please try Alt+Ctrl+S (this key is default) with Visual Assist.

In the new version of Visual Studio supports navigating to functions, classes or whatsoever structured information in the workspace. With Visual Studio 2010, it also helps us to find the symbols in the windows and MFC header files as well. See the screenshot below, I searched for OnTimer function and it display OnTimer function with all associated classes. We can also opt only for the internal items (in the current workspace) by checking the box available at the bottom.

Even it’s a powerful feature, as the most other intelli-sense features it’s working very slow. The initial search is costly but it’s nice to get something useful without spending additional bucks.

BTW, you can pop-out this dialog using Ctrl+,

See the screenshots below

image

image

 

Visual Studio 2010 – Right Angle bracket implementation (C++ 0x)

 

Those who dealt with template classes and template of template classes may have faced compilation error due to right angle bracket ( >> ) even the syntax appeared to be correct.

For e.g if we take the following code snippet

// This is not valid syntax in standard C++.
std::vector<std::vector<int>> incorrect;
// Adding whitespace between the brackets yields the correct parse.
std::vector<std::vector<int> > correct;

If you look at the OK syntax you can see a space between the ending right angle brackets. We may wonder we had given the right syntax and compiler did not interpret it well. In C++ as you know the notation for right shift operator is also similar – ( >> ). This actually confuses the compiler. In computer programming this is called Maximal Munch

In C++ 0x, there were a proposal to remove this inconvenience and the committee has accepted it. Visual C++ 2010 compiler implemented this as standard.

Now we can simply declare without worrying about maximal munch of C++ compiler.

// This is a  valid syntax in standard C++ 0x.
std::vector<std::vector<int>> correct;

Let’s take bit more complex example

template<int i> class X { /* ... */ };
X< 1>2 > x1;    // Syntax error.
X<(1>2)> x2;    // Okay.

template<class T> class Y { /* ... */ };
Y<X<1>> x3;     // same as "Y<X<1> > x3;".
Y<X<6>>1>> x4;  // Syntax error
Y<X<(6>>1)>> x4;".// . Instead, write like this. right shift operator is properly interpreted.

The new implementation may break some of the existing source code as well.

std::cout << (Y<X< 1>>::c >::c>::c) << '\n'; // C++ 98 source

The above code is perfectly valid in C++ 98 standard and it’s supposed to do right shift after constant “1″ but as per the new standard this may treat differently and give different output. Right usage of paranthesis is a solution to avoid these kind of issues. You can see more details about this proposal and implications here.

 

Visual Studio 2010 Tips – Cut-Copy operations on unselected lines

 

Visual studio editor contains all tid-bits for programmers. The editing capabilities are amazing as always; we know. In this post, I am talking about the behavior of unselected lines.

Knowingly or unknowingly you might have experienced, we can copy an entire line by just pressing Ctrl+C without selecting it.

Ctrl + C Copy the current line (including new line)
Ctrl + X Cut the current line (including new line)
Ctrl + L Delete the current line and copy to clipboard
Ctrl + Shift + L Delete the current line only

You can also control the Cut – Copy behavior at options page (Tools->Options->Text Editor->All Language->General). Note that this option can be controlled independently for each language type. It’s all your convenience.

image

 

Proudly powered by WordPress
Theme: Esquire by Matthew Buchanan.