I'm not sure if what I'm asking for qualifies as a full-fledged add-in, but here goes...
I'd like to put an option in one of the menus (Edit, perhaps) that gives me the opportunity to clean my text-- namely, sometimes in the course of business my quotation marks around strings wind up "slanted" instead of straight up and down, a consequence of cutting and pasting from outside sources.
It would be great to have a "clean quotes" option in VS that does a search and replace in the current document and puts in the correct quotes. How might I go about doing this, and thanks for the advice.
The easiest way to do this is under the Tools menu. Click Tools->External Tools... You can specify any program you want using macros for the current directory/file etc. You will have to find/create the tool to do what you want, but it is pretty simple to add. You can also go to the Tools->Customize... dialog to add a toolbar button or key binding.
For your particular problem you could very simply write a little command line to to fixup your file for you or use use something like sed.
Are you saying you have different fonts in your code window? This doesn't happen to me. I can't make this happen to me. There is only one font for the code at a time.
Can you provide a concrete example?
Related
If there are lots of projects in one solution and each of them has lots of .cs file.
Also, there might be one more classes in one file.
So, what I want to ask is: How can I find a file or a class quickly?
I really don't like use the ctrl+F every time.
Is there any plugin like if I click the CTRL+SHIFT+R it will open a window of show a class list or a file list and I can input the keyword what I'd like to find.
Then, when I double click the result, the file will be opened for me.
In VS2010 at least, there is the Navigate To feature. It indexes file names, classes, and methods for quick searching. Hit Ctrl+, (comma) to bring up the dialog:
Also, if you don't mind paying (and getting additional features), there is Visual Assist X and ReSharper, both of which I believe support VS2008/VS2010 and have source navigation features.
You can try out the "Productivity Power Tools" extension for VS2010.
It adds a new menu called "Solution Navigator", which has a search box with autosuggest, that enables searching your solution.
it has lots of other features and I highly recommend it.
I'm using VS 2010 with resharper. If I have a class called ConfigParserTests and then write
new ConfigParser(
the code will auto complete to
new ConfigParserTests()
which is not what I want. Any idea how to disable this nasty feature.
[Edit]
What is want is to write out
new ConfigParser()
without pressing "Esc". In this case I am using TDD so ConfigParser does not exist.
[/Edit]
I have been looking around in both the resharper and VS intellisense menus without finding anything helpful.
Open Options window, navigate to Intellisense > Autopopup. You will see auto-complete options correspond to several cases and categorized according to language:
As you see, you can select for each single case:
Do not display.
Display but do not preselect. (seems proper for your case)
Display and preselect. (default)
Different options may be selected in different cases or languages. For example, you can specify different behaviours in C#:
After dot
After 'new'
In doc comments
Letter and digits
Where value is expected
HTH
It's not clear whether you're complaining about which class name it's filling in, or the parentheses. I'll address both.
If the class you're trying to use is in another namespace, and you haven't added the appropriate using yet, then the code completion is doing just what you would expect -- you told it which namespaces to use, and you didn't tell it to use the one with ConfigParser in it; so it uses the nearest match, as expected.
But ReSharper has shortcuts that can save you work by finding the class and adding the using for you. For this case, I would suggest that you look into the different Ctrl+Space options in ReSharper. You could write new cp <Ctrl+Alt+Space> and ReSharper will give you a pop-up menu asking whether you mean ConfigParser or ConfigParserTests. When you hit Enter to select the one you want, it will add the necessary using to the top of your file, and complete new ConfigParser() with the cursor between the parentheses.
(If the ConfigParser class doesn't exist yet, then that's one of the cases where you don't want code completion. Just type new ConfigParser and then hit Esc before typing your open paren.)
If your problem is that it adds a close paren, be aware that if you type ) ReSharper will not add a second close parenthesis -- it will recognize that you're typing a paren that it already added, so it will just move the cursor to the right. If for some reason you still don't want it to complete the open paren for you, #jdv-Jan de Vaan's answer explains where to change this preference.
When doing TDD you should put the VS intellisense into suggestion mode instead of the normal completion mode.
The difference is described here
Unfortunately Resharper takes over the intellisense so you can not change mode without deactivating resharper.
Select Resharper \ Options. From the list on the left, select Enirionment \ Intellisence \ Completion behavior.
Then disable the checkboxes under "Automatically complete single item with:"
If you are using resharper 6.0 I would upgrade to 6.1 as there were a lot of these sort of preselecting bugs introduced in 6.0 and fixed in 6.1.
CTRL+ALT+Space Bar
Gotta give props to Zain for showing us how to get around these issues when utilizing TDD
http://blogs.msdn.com/b/zainnab/archive/2010/01/22/intellisense-suggestion-mode-vstipedit0012.aspx
Select Resharper \ Options \ Environment\ Intellisence \ Completion Behavior
Then Change the options under “Automatically insert parentheses after completion: can disable all together Really Old Man Voice I want to type my own (), Opening Only, or Young Hip Coder Dude I like resharper to do it all for me man
ViM has this option hlsearch where a searched string is displayed in highlight mode at all places in the file it is found. Is there a way to do the same in Visual Studio?
That is, if I search for "foobar", then all the foobar in the file are shown highlighted and this display remains until my next search. I find this very useful to see the places in a function where a certain variable is used (without having to manually search for the next appearance of that string).
I am aware of the Visual Studio Task List which can be used to look up strings like TODO. I hope the reader realizes that this is not a good fit for my problem which is more general text search and highlight.
If you like vim and are using Visual Studio you may want to check out Viemu.
The hlsearch Feature is of course included.
Example Picture:
Viemu hlsearch http://dklein.taunus.de/viemuhlsearch.png
With best regards.
Visual Assist X does this, along with something akin to light-symbol-mode. Among other things, of course.
Visual Studio 2010 now supports Reference Highlighting. Click on or move the cursor to any symbol such as names of variables, classes, methods, properties, etc. and it will highlight all other references in the file. It also allows you to navigate between the references using:
ctrl+shift+down arrow or ctrl+shift+up arrow
I use the RockScroll add-in. It has multiple features, one of them is that if you double click on a word it will be highlighted everywhere in the file. This is very similar to what you describe. It is free (as in beer).
If you happen to really like Vim, you might want to look into ViEmu for Visual Studio . I'm just a really happy user of it :)
For C# Visual Studio uses 4 spaces by default, whereas for C++ it is hard-tabs. Why is it so? Why is it different?
My project consists of both C# and C++ code and the difference really annoys me. I want to set a common standard for all the sources, but I wonder if this would have any drawbacks.
If you're looking for a completely logical, well reasoned justification for this difference I don't think you'll find one. Despite the many flame wars around tabs vs spaces there really isn't a real winner (otherwise the war would be over).
The way to get around this is via a .vssettings file. When I first started with VS 2005, I set the tabs/spaces default in each language. You can do this via Tools -> Options -> Text Editor -> (C#/C++). Then I export the tab settings into a .vsssettings file. Whenever I install VS on a new machine I just import that file and I have my happy space/tab settings.
PS: spaces rule :)
Of course tabs is the only right way. Tab can do everything spaces can do. Spaces cannot do much of what tab can do.
Tabs allow easy change of indentation and easy navigation without having to press arrow keys too many times, and would having to hold control.
The real solution is to have the editor be able to navigate and tab indented file as if it was space indented, if the user prefers so. The file would be saved with tabs. Very simple and accommodating everybody.
The problem in c# 2010 is that I cannot find any option to change it to tabs.
I doubt there are any drawbacks as C++ grammar doesn't distinguish between tabs and spaces.
By the way, I think the best way to set code style standards is to export VS settings and share it with the team.
The reason behind C#'s default 4 spaces is that whoever will open the file the indentation will be the same.
You are free to change it as you like in preferences.
Just go with whatever you prefer, I normally use tabs in C++. Those who view my code all use the default VS settings RE tabs anyway so there is no real pull to replace that with spaces. I'm not sure what its like now but when F# was in its infancy (i.e., pretty early release out of MSR) you needed to use spaces in #light code otherwise the compiler would complain as whitespace was important.
Different people have different preferences, I know some who religiously use spaces, on the other hand I know more that uses tabs.
For C# Visual Studio uses 4 spaces by default, whereas for C++ it is hard-tabs. Why is it so?
Why not?
Just change it if you're not happy.
Spaces make it more difficult to navigate through code with the keyboard.
With spaces, most people will use four spaces, but some will use two or three. With tabs, the people who want their code tabbed out with two spaces can simply set the tab character to display as wide as two spaces, and the coding style remains consistent.
If you're using spaces for tabs in any HTML, CSS, or JavaScript, you're doing it wrong. There's no tabs-vs-spaces debate for html/css/js - it's either tabs, or ignorance. Client-side code is not compiled, and IIS doesn't have compression turned on by default - excess white space = excess fat.
Way back when, VB6 didn't give us the choice to use tabs, but now we can and should - if you don't, your code makes it look like you're still clinging to old-school ways.
So stop coding like it's 1999. Use tabs. Do it for the children.
The tabs vs spaces argument has a simple answer: tabs. Tabs allow you to specify your indentation while not forcing others to live with it. Given that tab sizes are merely a personal preference, one user shouldn't be able to force others to follow his/her display options.
Why the difference between C++ and C#: no clue. However, knowing that tabs are logically a better option, just change the C# (and in fact, all languages) to tabs and voila.
I find the solution explorer is a bit slow to get around in sometimes, and think that there might be a better UI solution out there. I like Ctrl+T but sometimes a visual cue is better than remembering the class name?
I think it would be nice you had a second, similar window, that only shows files that have been opened during the current session? Any other suggestions
If you want to upgrade your experience to the next level, you need to have Visual AssistX.
It enables links between your code and the files it comes from. And it's also light-weight. You will forget the Solution Explorer quite rapidly.
http://www.wholetomato.com
In the toolbar's search box, you can type ">of ". It will give you an intellisense-like dropdown of files in your solution as you type out the filename (e.g. ">of def" will show "default.aspx" and "default.aspx.vb" if those two files are in your solution).
I'm not sure if this any more/less cryptic than ctrl+t, but I thought I'd throw it out there.