VS2015: Can I mark down code? - visual-studio

When I'm working at someone else's code, sometimes it happens that I've found something useful that I likely will need to return later to.
Except the chances are that I forget where I've found that part and then I need to find it again. Nowadays I'm mostly using breakpoints to set these down, But I don't need these breakpoints for debugging, so I don't think that's the most efficient method. Something that could work for me is a sort of marker that functions marking down like a breakpoint, but does not affect debugging.
Will all these ways of breakpoints, search functions, finding references, and adding a Watches. I do have a feeling that such feature is present in Visual Studio already. But I havn't found it yet, I've already tried searching it up, but it looks like it hasn't asked before.
So, is there a feature in Visual Studio that let you mark down code like breakpoints, but just for the purpose of marking down?

There is more than one way to do so.
If I finde something interesting I mark it with a Bookmark.
Just STRG + K, STRK + K and it will be places on your current row.
With these Buttons you can switch to your bookmarks or delete them all. They are client based.
Visual Studio also gives you a "To Do List" Function. This one is triggered by comments in the code and seen for everyone with the right options used.
See here how it works in detail.

Yes, it's called a bookmark. This little toolbar is for bookmarks:
You can also use the Edit, Bookmarks... menu item and the View, Other Windows, Bookmark Window which among other things lets you see all of them and give them names.
One caveat: the bookmark binds to the line number, and doesn't move if you add or remove lines. So if you bookmark the first line of a function, then make changes above that, the bookmark won't be on the first line of a function any more.

Related

Is there a way to properly dump the navigation history in Visual Studio?

Very frequently, I will be looking for a specific section of code where something happens, and will reach there by starting at a function at a high level of abstraction and go lower by successively opening the code of called methods. Eventually I will find what I'm looking for, and I would like to save the path that I took to get there - which is pretty much what the call stack would be if I had put a breakpoint in that code and stopped here at runtime, except that I'm just inspecting the code.
I'm aware the little arrow next to the "Back" arrow lets me somewhat get that in the UI and I can then take a screenshot of what I'm shown, but that's not a fantastic solution. The names of the functions are trimmed (leading to cases where it could match several functions), the line number is seldom shown (only if there was no code at that line), and I would much rather have the text format to begin with so I can copy the function names into a search tool rather than type them from the screenshot later.
So I was wondering: is there a way to dump the navigation history in Visual Studio ?
Where I could for ex. ask for the last 50 cursor positions, and get the file, file path, line number & possibly the code at that line in text format or some more intelligent thing, should the IDE support that.
Thanks.
PS: I found this very similar question Is there extension for viewing navigation history in Visual studio? that's >5 years old and didn't have a satisfying answer, so I'm trying my luck again, hoping things have changed since if there was no solution back then.

VisualStudio 2019 - expand all regions below and including

Is there a command/macro/keyboard shortcut that will expand the region where the cursor is and expand all collapsed regions inside it (recursively) ? if not can that be achieved ?
Short answer
As far as I know - No. There isn't a single shortcut that does that.
How to implement it by yourself
It's quite easy to create a plugin for Visual Studio that does exactly that:
Get the cursor location.
Store the 'start' and 'end' line numbers
For each line:
If it contains a region - expand it.
Few examples to begin with:
https://github.com/LeonalaDiantes/RegionsWasher
https://github.com/dnperfors/RegionExpander
https://github.com/fsdsabel/ExpandRegions
https://github.com/pauljmelia/regionsareevil
https://github.com/yasam100/CodeRegionsSnippets-VSExtension
Some of the projects are very close to the thing you have in mind, so you might even fork it and do your changes.
:-)
Another option
you might get the same result by using Macros for Visual Studio Editor/Recorder:
And then, write a macro like this one or maybe even record the steps you like to "run".
IMO, with recording and playing it will be a little harder to achieve.
but I'll be happy to be proved wrong.
I had the same problem, the following worked for me without having to make a macro or a plugin. Note, this is only a partial solution to the problem. I got it to expand recursively underneath a function, but I'm not sure how to reverse it (i.e. recursively collapse everything under the function again). To recursively collapse everything again, I could only figure to use (Ctrl+M, Ctrl+L), which collapses/expands everything in your file, but then you have to drill back down to the function you want.
Firstly, I got everything in a collapsed state by pressing (Ctrl+M, Ctrl+L). You may have to use that combination twice to get everything to collapse. Then I expanded a class and drilled down to the function I wanted to work on.
With the function in its collapsed state, I highlighted the single collapsed row it was on and pressed (Ctrl+M, Ctrl+M).
Doing so recursively expanded everything under the function.
I hope this partial solution helps someone who doesn't want to make a macro or plugin.
I believe ctrl + k followed by ctrl+] should unfold all subregions
replacing the ] with [ should fold all subregions.

What is the keyboard shortcut to type fast in Visual Studio?

I am not sure what is the best way to word my question correctly in single line. But basically I have seen quite a few video tutorials now where the coder types really fast using some sort of shortcut to fill in the automatic text(prolly intellisense stuff) It looks very similar to Linux command line tab where you only type half of your text and when you hit tab it either fills in the gap or show you the remaining options.
Hope that makes sense.
Thanks
Pressing Ctrl+Space completes the current variable/class you are typing.
Typing things like ctor and then pressing the Tab key twice tells Visual Studio to insert a constructor for you. (Also works with for for a for loop, cw for a Console.WriteLine();, etc.)
For a full list, please refer to the official reference from MSDN.
I believe its Ctrl-Space, which is pretty common among most IDE's

Improving development flow and editing with XCode.

XCode is a little weak in the way that it obliges you to format code, and the restrictions it places on you. I'm thinking of things such as select a block of code and use tab to reposition the whole block, which is very useful for cleaning up indenting, amongst other things.
I realise that I can use an external editor (such as Sublime Text 2, which is superb and my daily editor) to edit code, but I'm wondering if there are any plugins or tools which exist out there which integrate into xcode to improve this development experience.
What kind of extensions exist for xcode, or if there aren't any, are there any lesser-known features which assist in improving this?
It's hard to give you an answer, as we don't know what features you use elsewhere that you think are missing in Xcode. For example, you can move a block of code in or out by pressing Cmd-{ or Cmd-}. Or you can "fix" the indenting by using ctrl-i as jrturton pointed out above. All of the emacs keybindings work. In fact, you should look over the key bindings in the prefs to see what other things are possible. Some of my favorites are:
1) Select a word and hit Cmd-E to make it the search term. Then Cmd-G to find the next instance.
2) F6 to step over in the debugger, F7 to step in and F8 to step out
3) As much as I hate command lines, gdb has a number of useful commands for calling methods while stopped at a breakpoint. You can call any function or C++ or Objective-C method using the call command. (Type help call at the gdb prompt to learn more.)
4) If your index is up-to-date, you should be able to Cmd-click on a symbol to go to it's definition, or option-Click to see its documentation.
Are those the sorts of things you're looking for? If not, please give examples of what you want. As far as I know there is no plug-in mechanism in Xcode 4, so no extensions exist.
Though the first answer is a great one (learned a lot from it), I wanted to add a little hint that helps me a lot when pasting codesnippets. A lot of times xCode copies indentation in a way I don't like and then I have to reindent the whole snippet.
What I started to do is jump to the first char in line (ctrl + a | cmd + ArrowLeft) and either paste the code immediatly, or indent by one or two before pasting, dependend if I'm in a function, loop etc.

Alt + Enter doesn't use appropriate quick fix in Resharper

I worked with Resharper 5 before and when I have a problem in code (for example unsuitable space around a parentheses), I used Alt+Enter and Resharper fixed the problem. But in V6, this doesn't fix the problem, it generate a supress statement! What should I do?
Here is more detail:
1- I have this line in my code:
if (this.RequestClose!= null)
Resharper draw a blue line under it and warn that the space around != is not correct.
In Resharper 5, I could press Alt+Entyer two times to fix the spacing problem. In Resharper 6, if I press Alt + Enter two times on this line, nothing happens.
2- I have this line in my code:
var view = new AddressDetailView();
view.DataContext = viewModel;
Resharper suggests using object initializer, but pressing Alt+Enter twice doesn't fix it.
Resharper 6.1 solved this problem!
Did you actually look at the menu item you're selecting? (I'm guessing not, since your question includes no mention of what's in the menu.) Alt+Enter brings up a pop-up menu, you know. By pressing Alt+Enter twice, you're just selecting the first item in that menu.
ReSharper 6 has new features, therefore it has more options in the list, therefore the order is sometimes different. The quick fixes are almost certainly still working; it's just that the first quick-fix in the list isn't always the same one as in R#5.
The solution is simple: read what's on the screen before you select it. If the quick-fix you want isn't the first in the list, then cursor to the one you want before you hit Enter.
(There's never been a ReSharper version where it's safe to always accept the first item in the menu -- the options change depending on whether R#'s background scanning has completed yet or not. If you've been blindly accepting the first item every time, I'm surprised you haven't gotten bitten before now.)
I could not find any way to fix this problem and decided to use R# 5.1 with Style cope instead.

Resources