Visual Studio: automatically open Intellisense - visual-studio

Is there a way to make Intellisense(CTRL+Space) automatically open after I type a letter? Its really annoying me to have to press CTRL+Space every line of code

What you describe is the default behavior. To restore it, use:
Tools -> Options -> Text Editor -> C# (e.g.)
Statement Completion -> Auto list members: Checked
Edit:
In C++ "Auto list members" does not apply to the first identifier in an expression, that is, when the identifier could be almost anything: a global variable, a keyword, a class member, etc. It does however apply (and does work) after the ".", "->", and "::" operators.
A workaround for a very common case of desiring auto listing for class members is to use the "this->" convention in your code, which some coding standards recommend anyway. The completion list will pop up immediately upon typing "->".

Default C++ IntelliSense does not open automatically when you are typing except for after ., -> and ::. The third party commercial extension Visual Assist X does provide that behavior though.

Related

Visual Studio - What are suggestion and standard completion modes

In Visual Studio, there's a button on the toolbar with tooltip:
Toggles between suggestion and standard completion modes. (Ctrl+Alt+Space)
My guess is that these have something to do with IntelliSense, but I'm not sure.
What is suggestion mode and what is standard completion mode?
The difference seems to be in whether completion is committed when you type keys that are not explicit commit keystrokes while typing. Tab is an explicit commit character; . and ; are examples of keys that are not explicit commit characters.
If I type "foo".sub( (in C# as an example) the behavior will be as follows:
with the button enabled (suggestion mode), I will get the same literal output with a closing parenthesis added: "foo".sub()
with the button disabled (standard mode), it completes using the best match in the completion list: "foo".Substring()
Turning this behavior on is more suitable in languages or projects where you are invoking dynamic (or new, not-yet-existing) methods and properites that are not present in the completion list, so that you don't have to fight with undesired partial matches.

Over-enthusiastic Intellisense in VS2010 - can I tweak it?

Since I have upgraded from VS2008 to VS2010, I've been having an increasingly infuriating battle with the Intellisense.
For example, when specifying CSS styles, when I press Enter to start an new line, Intellisense (appropriately) lists available Styles to me. And if I select color and then type ':', it presents a list of color presets - often helpful. However, if I type in a space (I like them for readability) or if I type '#' to enter RGB values, it selected the default Intellisense selection, in this case inherits.
Another example is in an ASP.NET page - say I am concatenating strings, I type myString =, I get an Intellisense pop-up. If I type space or '"' (to enter a literal) or '.' (so select a property or method within a WITH block), the Intellisense selects the first entry in the list.
I can dismiss the Intellisense pop-ups with escape but it makes it incredibly slow to code.
This behaviour is different to my VS2008 set-up. I can't seem to find any way to configure Intellisense to behave differently... I really only want it to select and Intellisense entry when I type or ... at least, certainly not when I type '"' or ' ' or '.'!
Problem solved:
Being the idiot that I am, I hadn't properly checked for extensions; when I did, I found I had the Intellisense Presenter extension installed, and digging further it appear that my experience is not unique. It's a promising extension, but is currently unusable in this state.
This isn't normal. Start with Tools + Import and Export, select Reset all Settings. Next step is to run devenv.exe with the /safemode command line argument so it runs with all add-ins disabled.

Xcode: view references for a variable?

I am new to Xcode. I am not sure if there is a way to view a variable's references just like "Find all references" in Visual Studio by right click on a var?
For example, in my .h file, I would like to know or view all the references for property isSet:
#interface MyInterface {
...
BOOL isSet; // view all references to this var?
...
}
Try using: Find in project -> As symbol context menu. Sometimes you may want to search as definition instead.
Beside Xcode, there is AppCode IDE from JetBrains. And in AppCode it is easily possible, just select Search --> Find Usages.
I was looking for similar option. I do not know why XCode did not included that.
But there is a work around I use until Apple give that option in XCode.
Try this in the source code (.m) file,
Select the symbol, right click -> Refactor -> Rename
-> Give a name whatever you wish, then press Preview.
Now you can find all the references. Now you can Cancel it or do not rename it. :)
i'm using xcode ver 4.5 and i can select the method or property, right click and pick Find Selected Text in Workspace...
You're conflating two different things in your question: finding references to a variable, and finding references to a property. Finding references to a property can be done via the 'Related Files' menu, as described in my answer here: https://stackoverflow.com/a/17931752/1709587
Finding references to a variable can be sort-of done via 'Find Navigator' tab of the Navigator. (That's the magnifying-glass-icon tab of the left side menu.) Go to Find -> References -> Matching and type in the variable you're looking for. That said, I can't see that this is particularly useful, because:
It will match all occurrences of a variable with that name, even if they're unrelated to the particular variable you're looking for.
Why would you ever need this? You shouldn't generally be using public member variables (use properties instead), so 99% of the time, all references to the variable you're interested in will be within the file in which it is declared. Just using cmd+f and doing a simple text search within that file has always sufficed for me, and I've never felt the need to bring out heavier machinery. If you hit a couple of comments while doing this, who cares?
If you truly, truly do need the functionality you're asking for, and neither the 'Related Files' menu, Find -> References, nor a simple text search will do, then your only options are to use some third party tool like AppCode or the (cumbersome, slow) 'refactor' hack proposed by Karim.
Update for XCode 12: right click on definition -> Show code actions -> Callers...
This will show every place in the project where this method or property is referenced.
Find selected symbol in workspace is what you need
right click on the method/property -> Find -> Find selected symbol in
workspace
focus the property/method and press ⇧ + ⌃ + ⌘ + F (or you
can have a custom one)
Does basically the same search as Refactor -> Rename does

Text Macros in XCode not working?

Noob xcoder here and for some reason i cannot get the text macros to expand within xcode. For example if i type ifelse and then hit ^. it doesnt automatically expand the macro?? Likewise if i type fo and then ^. it will complete it to either for,fori etc, and will also pop up those options if i hit escape however i cannot get it to expand the macros unless i am misunderstanding how this works?
Make sure the shortcut for menu item Edit->Next Completion is indeed ^. If it is not, go to Xcode preferences, Key Bindings and edit it.
Try rebuilding your code sense index from the Project Info panel.

Hidden Features of Visual Studio (2005-2010)?

Locked. This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions.
Visual Studio is such a massively big product that even after years of working with it I sometimes stumble upon a new/better way to do things or things I didn't even know were possible.
For instance-
Crtl + R, Ctrl + W to show white spaces. Essential for editing Python build scripts.
Under "HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\8.0\Text Editor"
Create a String called Guides with the value "RGB(255,0,0), 80" to have a red line at column 80 in the text editor.
What other hidden features have you stumbled upon?
Make a selection with ALT pressed - selects a square of text instead of whole lines.
Tracepoints!
Put a breakpoint on a line of code. Bring up the Breakpoints Window and right click on the new breakpoint. Select 'When Hit...'. By ticking the 'Print a message' check box Visual Studio will print out a message to the Debug Output every time the line of code is executed, rather than (or as well as) breaking on it. You can also get it to execute a macro as it passes the line.
You can drag code to the ToolBox. Try it!
Click an identifier (class name, variable, etc) then hit F12 for "Go To Definition". I'm always amazed how many people I watch code use the slower right-click -> "Go To Definition" method.
EDIT: Then you can use Ctrl+- to jump back to where you were.
CTRL+SHIFT+V will cycle through your clipboard, Visual Studio keeps a history of copies.
Sara Ford covers lots of lovely tips: http://blogs.msdn.com/saraford/archive/tags/Visual+Studio+2008+Tip+of+the+Day/default.aspx
But some of my favourites are Code Snippets, Ctrl + . to add a using <Namespace> or generate a method stub.
I can't live without that.
Check out a great list in the Visual Studio 2008 C# Keybinding poster: http://www.microsoft.com/downloadS/details.aspx?familyid=E5F902A8-5BB5-4CC6-907E-472809749973&displaylang=en
CTRL-K, CTRL-D
Reformat Document!
This is under the VB keybindings, not sure about C#
How many times do you debug an array in a quickwatch or a watch window and only have visual studio show you the first element? Add ",N" to the end of the definition to make studio show you the next N items as well. IE "this->m_myArray" becomes "this->m_array,5".
Incremental search: While having a source document open hit (CTRL + I) and type the word you are searching for you can hit (CTRL + I) again to see words matching your input.
You can use the following codes in the watch window.
#err - display last error
#err,hr - display last error as an HRESULT
#exception - display current exception
Ctrl-K, Ctrl-C to comment a block of text with // at the start
Ctrl-K, Ctrl-U to uncomment a block of text with // at the start
Can't live without it! :)
Stopping the debugger from stepping into trivial functions.
When you’re stepping through code in the debugger, you can spend a lot of time stepping in and out of functions you’re not particularly interested in, with names such as GetID(), or std::vector<>(), to pick a C++ example. You can use the registry to make the debugger ignore these.
For Visual Studio 2005, you have to go to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio \8.0\NativeDE\StepOver and add string values containing regular expressions for each function or set of functions you wish to exclude; e.g.
std::vector.*::.*
TextBox::GetID
You can also override these for individual exceptions. For instance, suppose you did want to step into the vector class’s destructor:
std::vector.*::\~.*=StepInto
You can find details for other versions of Visual Studio at http://blogs.msdn.com/andypennell/archive/2004/02/06/69004.aspx
Ctrl-F10: run to cursor during debugging. Took me ages to find this, and I use it all the time;
Ctrl-E, Ctrl-D: apply standard formatting (which you can define).
TAB key feature.
If you know snippet key name, write and click double Tab. for example:
Write
foreach
and then click tab key twice to
foreach (object var in collection_to_loop)
{
}
2. If you write any event, write here
Button btn = new Button();
btn.Click +=
and then click tab key twice to
private void Form1_Load(object sender, EventArgs e)
{
Button btn = new Button();
btn.Click += new EventHandler(btn_Click);
}
void btn_Click(object sender, EventArgs e)
{
throw new Exception("The method or operation is not implemented.");
}
btn_Click function write automatically
in XAML Editor, Write any event. for example:
MouseLeftButtonDown then click tab
MouseLeftButtonDown="" then click tab again
MouseLeftButtonDown="Button_MouseLeftButtonDown" in the code section Button_MouseLeftButtonDown method created.
Sara Ford has this market cornered.
http://blogs.msdn.com/saraford/default.aspx
More Visual Studio tips and tricks than you can shake a stick at.
Some others:
The Visual Studio 2005 and 2008 3-month trial editions are fully-functional, and can be used indefinitely (forever) by setting the system clock back prior to opening VS. Then, when VS is opened, set the system clock forward again so your datetimes aren't screwed up.
But that's really piracy and I can't recommend it, especially when anybody with a .edu address can get a fully-functional Pro version of VS2008 through Microsoft Dreamspark.
You can use Visual Studio to open 3rd-party executables, and browse embedded resources (dialogs, string tables, images, etc) stored within.
Debugging visualizers are not exactly a "hidden" feature but they are somewhat neglected, and super-useful, since in addition to using the provided visualizers you can roll your own for specific data sets.
Debugger's "Set Instruction Pointer" or "Set Next Statement" command.
Conditional breakpoints (as KiwiBastard noted).
You can use Quickwatch etc. to evaluate not only the value of a variable, but runtime expressions around that variable.
T4 (Text Template Transformation Toolkit). T4 is a code generator built right into Visual Studio
Custom IntelliSense dropdown height, for example displaying 50 items instead of the default which is IMO ridiculously small (8).
(To do that, just resize the dropdown next time you see it, and Visual Studio will remember the size you selected next time it opens a dropdown.)
Discovered today:
Ctrl + .
Brings up the context menu for refactoring (then one that's accessible via the underlined last letter of a class/method/property you've just renamed - mouse over for menu or "Ctrl" + ".")
A lot of people don't know or use the debugger to it's fullest - I.E. just use it to stop code, but right click on the red circle and there are a lot more options such as break on condition, run code on break.
Also you can change variable values at runtime using the debugger which is a great feature - saves rerunning code to fix a silly logic error etc.
Line transpose, Shift-Alt-T
Swaps two line (current and next) and moves cursor to the next line. I'm lovin it. I've even written a macro which changed again position by one line, executed line transpose and changed line position again so it all looking like I swapping current line with previous (Reverse line transpose).
Word transpose, Shift-Ctrl-T
When developing C++, Ctrl-F7 compiles the current file only.
Document Outline in the FormsDesigner (CTRL + ALT + T)
Fast control renaming, ordering and more!
To auto-sync current file with Solution Explorer. So don't have to look where the file lives in the project structure
Tools -> Options -> Projects and Solutions -> "Track Active Item in Solution Explorer"
Edit: If this gets too annoying for you then you can use Dan Vanderboom's macro to invoke this feature on demand through a keystroke.
(Note: Taken from the comment below by Jerry).
I'm not sure if it's "hidden", but not many people know about it -- pseudoregisters. Comes very handy when debugging, I've #ERR, hr in my watch window all the time.
Ctrl-Minus, Ctrl-Plus, navigates back and forward where you've been recently (only open files, though).
I don't use it often, but I do love:
ctrl-alt + mouse select
To select in a rectangular block, to 'block' boundaries.
As noted in comments,
alt + mouse select
Does just a plain rectangular block.
Here's something I learned (for C#):
You can move the cursor to the opening curly brace from the closing curly brace by pressing Control + ].
I learned this on an SO topic that's a dupe of this one:
“Hidden Secrets” of the Visual Studio .NET debugger?
CTRL + Shift + U -> Uppercase highlighted section.
CTRL + U -> Lowercase the highlighted section
Great for getting my SQL Statements looking just right when putting them into string queries.
Also useful for code you've found online where EVERYTHING IS IN CAPS.
Middle Mouse Button Click on the editor tab closes the tab.
To display any chunk of data as an n-byte "array", use the following syntax in Visual Studio's QuickWatch window:
variable, n
For example, to view a variable named foo as a 256-byte array, enter the following expression in the QuickWatch window:
foo, 256
This is particularly useful when viewing strings that aren't null-terminated or data that's only accessible via a pointer. You can use Visual Studio's Memory window to achieve a similar result, but using the QuickWatch window is often more convenient for a quick check.

Resources