Any Way to Double-Click Diff Line in Sourcetree and Move to That Line In Visual Studio? - visual-studio

I doubt this can be done ... maybe there is a feature close to it? Looking to seamlessly transfer from Sourcetree to Visual Studio at the correct line when double clicking that line in the diff display. Seems like a very useful feature don't know why it hasn't been implemented already.

Related

Refactor on save in Visual Studio 2019

I love Prettier for VS Code. I want to do similar things in Visual Studio (2019).
It now has 'Wrap, indent, and align parameters or arguments' for example (https://learn.microsoft.com/en-us/visualstudio/ide/reference/wrap-align-indent-parameters?view=vs-2019); and I'd like to do this automatically whenever I save the file.
Does anyone know if this is possible? Or if there's a free extension that can do this?
Mads Kristensen (a Microsoft employee who makes scads of Visual Studio extensions and teaches you to too!) made a JsPrettier extension for "classic" Visual Studio (ie, not VS Code):
https://github.com/madskristensen/JavaScriptPrettier
It does not format on save if you set that up in its settings.
If it's literally Prettier in Visual Studio that you're after, this isn't a bad option.
I don't know of a free plugin but you can get quite a long way towards this with some muscle memory and the built in autoformat command.
CTRL+E, CTRL+D, CTRL+S
will do code indentation and formatting, and save the file.
If you have Resharper (sorry), there's a configurable code cleanup tool which will do what you want and CTRL+E, CTRL+F, CTRL+S will do the cleanup and save.
The Format document on Save VS extension does exactly what you want, with one exception. It automatically runs Visual Studio's code cleanup command on save.
Visual Studio's code cleanup commands covers many code style preferences and can be configured with a .editorconfig file. Unfortunately one thing that is not supported by VS yet (not counting Resharper) is line wrap preferences. There is an open ticket for this: dotnet/roslyn#33872
If and when Roslyn supports line wrap preferences (presumably as a new .editorconfig preference), then Visual Studio code cleanup will enforce it and the extension will apply it on save.

Visual Studio Diff Tool - When is Editing Allowed?

I'm using Visual Studio 2013 and tfs 2013. Sometimes I'll make a code change and click compare with latest version. The diff tool will open and allows me to edit the file in the diff tool. However other times it will not let me edit but will read only.
Is there some setting or something I need to do for me always allow edit?
In a database project I've noticed that it never lets me edit in the diff tool. Is there some setting I need to change?
I've searched around online but haven't found any answers to this.
Thank you.
Editing in the Diff viewer is only allowed for certain file types. It doesn't support editing .sql files and there is no VS setting to allow that.
Visual Studio Diff Window: How to Edit .sql Files
Have you tried other diff tools like WinMerge or Beyond Compare?
In Visual Studio, go
Tools-->Options-->Visual Studio Team Foundation Server-->Configure User Tools,
add the extensions of the file types you would like to compare and under Command,
input the path of the diff tool (in my case it is Beyond Compare)
Other answers are correct as well but do not cover all the cases.
Visual studio will not allow you to edit file during compare if the panel you are trying to edit does not correspond directly to the file in your working directory.
You can easily tell by the address bar on top of the compare panel. If it ends with HEAD or Index - you will not be able to edit the file.

MSVC 2012 - Shortcut to duplicate line

What is the key for duplicating a line in Microsoft Visual Studio 2012?
(in Notepad++ it is ctrl+D )
Check this extension:
Duplicate Selection extension : http://visualstudiogallery.msdn.microsoft.com/830a6482-3b8f-41a8-97b5-b9c581e5ad8b
Duplicate the line without touching the clipboard (as Notepad++ does).
Just to make it absolutely clear
ctrl-C at the start of a line copies the whole line without your needing to select it
source Shortcut for duplicating a line of code in Visual Studio 11
Here's a list of keyboard shortcuts, but don't see a duplicate on it. Ctrl+C/Ctrl+V may be your best bet or see if there's something you can define under Tools>Options>Keyboard.

How to revert file in Visual Studio 2010 (reload the file from disc)

I'm starting to use Visual Studio (2010) after years with Eclipse.
Every now and then I've found Eclipse's "Revert" feature pretty useful, that is, to reload the file from disk, discarding all changes. (Nothing to do with version control reverting.)
How can I do this with Visual Studio? Should be pretty simple but I haven't found it yet.
I know that I can do this with "undo until *-indicator disappears" but that's pretty impractical.
Unfortunately I do not know of a built-in way to do this in VS other than closing the file and reopening it without saving.
There might be some extension that does this, but I am not aware of it :(
In the current version, you find in the Explorer, in the left sidebar. Then Open Editors, and right click on the file you want to revert.
If you are using git with Visual Studio:
Solution Explorer > Right Click On File > Git > Undo Changes

Configure Visual Studio to use UNIX line endings

We would like to use Visual Studio 2005 to work on a local copy of an SVN repository. This local copy has been checked out by Mac OS X (and updates and commits will only be made under Mac OS X, so no problem there), and as a consequence the line endings are UNIX-style.
We fear that Visual Studio will introduce Windows-style line endings. Is it possible to force Visual Studio to use UNIX line endings?
Warning: This solution no longer works for Visual Studio 2017 and later. Instead, both of the answers by jcox and Munther Jaber are needed. I have combined them into one answer.
As OP states "File > Advanced Save Options", select Unix Line Endings.
This will only affect new files that are created. Fixing any that were previously created can be done file-by-file or you can search for tools that will fix on-bulk.
Here are some options available for Visual Studio Community 2017
"File > Advanced Save Options" has been removed by microsoft due to "uncommon use". Whatever that means. https://developercommunity.visualstudio.com/content/problem/8290/file-advanced-save-options-option-is-missed.html
You can add it back by going to "Tools>Customize", then "Commands" tab, select the drop down next to "Menu Bar" select "File" then "Add Command">File>Advanced Save Options..". You can then reorder it in the file menu by using "move down".
I don't know if you will have to then set the advanced save options for each and every file, but it might prevent the issue I was having where my Visual Studio kept adding CL RF line endings into my files that were uniformly LF.
But I took it one step further and I added an extension called "Line Endings Unifier" by going to "Tools>Extensions and Updates>Online" and then searching for "line endings" in the search bar to the right. I will use this to automatically force all of my scripts to save with uniform line endings of my choice, but you can do more with it.
https://marketplace.visualstudio.com/items?itemName=JakubBielawa.LineEndingsUnifier
strip'em is another solution that does something similar to Line Endings Unifier. http://www.grebulon.com/software/stripem.php
I am not sure how they differ or the advantages/disadvantages of either. I'm mainly using Line Endings Unifier just because it was in the Visual Studio Marketplace. I think I've used all of these methods in the past, but my memory is fuzzy.
So I found this problem and the answers very confusing, especially since I primarily develop in Linux and PhpStorm and simply never have these issues.
I found that for Visual Studio 2019, only Munther Jaber's solution worked when combined with #jcox's .editorconfig changes for new files.
However, being unfamiliar with Visual Studio itself, it took me a LONG TIME to find out where the line ending box is...
SO I made a video of how to configure this.
https://youtu.be/YfN3igHXTPo
Update: I learned how to make animated GIFs via FFMPEG just so I could embed the video here!
VS2017 supports .editorconfig files, which can be checked in along with your project. This is the relevant command for setting Unix line endings:
end_of_line = lf
"File > Advanced Save Options", select Unix Line Endings works per file based.
Alternatively You can use Strip'em Add-in for Visual Studio
This Add-in converts the text format of a file when it is saved in Visual Studio.
More info here: http://www.grebulon.com/software/stripem.php
There are some VS extension that are useful to solve this problem
I will recommend Trim line ends on save. This extension is free and open source. There are similar extensions that may work for you, just go to TOOLS | Extensions and Updates and search online for "line end"
For Visual Studio 2019 for Mac
Go to Project> Solution Options> Source Code> Code Formatting> Text File
In the Line Terminations drop box select Unix/Mac.
Image
The LF is clickable and you choose either LF or CRLF.
It is possible to force line endings in Visual Studio 2017 for Mac
Go to Tools > Add Custom Tool....
In the dialog box that appears scroll the left menu down to the Text Editor section and select General.
In the first option, Line ending conversion, change Leave line endings as is to Always convert line endings.
In the latest version on Windows you go to
File > Preferences > Settings > Text Editor > Files > Eol

Resources