Vscode: Copy/replace/add left <-> right in compare views

Created on 4 May 2017  ยท  109Comments  ยท  Source: microsoft/vscode

In the compare views, it would be nice to have

  • "Copy to left/right"
  • "Replace left (with right)/right (with left)"
  • "Add above/down left/right"

in all views, i.e. the side-by-side and the unified view (there with other text than "left/right").

Now, I need to select the text and copy-paste it. In the unified view, I even can't select the text from the compared file ("left" file in side-by-side view).

A nice UI would be the one as in Meld:
image

Related: #24390 (but only wanted for staging VCS diffs)
Blocked by: https://github.com/Microsoft/vscode/issues/4180 ?

diff-editor feature-request

Most helpful comment

This is probably my biggest problem with VS Code so far. I was very surprised that this did not already exist.
Any chance that this will be added?

All 109 comments

Similar proposal by me following git merge inline actions- #30519

I miss that feature as well. Good old NetBeans has a a similar intuitive approach:

diff_netbeans-8 2

Only the right side can be edited though, but there's a "swap" button right above the diff to mitigate that ;-)

+1 This would be really useful to have. Any hope of this

This is probably my biggest problem with VS Code so far. We are trying to drop Intellij, which lets you compare any two files and copy right and left with ease.

I was very surprised that this did not already exist in VS Code. BBEdit isn't perfect, but it does have that.

+1

Super bonus points for allowing mapping to keys so i can create a vim-diff copy
(eg: do takes the other (usually left) side's changes)

This is a really good feature which I am looking forward to.

In most coding time, I need to diff and merge only two files. I just want to diff and merge and there is no need for me to use git diff for only two files.

In present, I use the tool "diff & merge" from jet brains IDE. This is a really good sample plate to reference.

I strongly suggest this feature provided in the future version of VSCode.

The diff & merge feature in JetBrains IDE

Many of us awaiting why not write it

+1

We need this so bad

This is probably my biggest problem with VS Code so far. I was very surprised that this did not already exist.
Any chance that this will be added?

+1

+1

+1

+1

As my proposal #30519 was closed as a duplicate of this one, pasting the text here-

Inline actions in diff view for copy, replace, previous and next

This proposal requests inline actions in diff view, like the inline merge actions are provided for git merge markers within the editor-
inline_diff

The code actions can be Copy to left/right/other side, Replace left/right/other side, Previous and Next (for going to previous/next diff). And as copying original is prohibited in inline diff view, there can be a Copy original action as well.

This proposal can be regarded as an implementation detail of the proposal #25887 .

+1

+1

+1

+1

+1

+1

+1

+1

+1

Just a comment: I noticed that i could edit the "right side" of Compare ... that is, my local copy.

This made it possible to take edits from the foreign file - but in the event i needed to sync the other way, i'd have to overwrite the foreign file with the local updated edit.

Merging the two files and then have VSCODE overwrite both would be awesome.

VS code need this.

I'm shocked no one has written an extension for this!

Meld is just so much better for this purpose.

+1

+1

+100000000000

+1

+1

+1

+1

I can diff 2 files but can't merge left or right? It's something I've been able to do in Vim for a decade...

This would be a great addition. I really like VSCode so far. If you add this functionality that would make me love VSCode!

Definitely needed

This needs to be added ASAP!

@Microsoft why you don't just make vscode open source? I think of it would be open sourced new useful features would appear more and more faster than waiting while you handle it

@xahon ... Guess why you are commenting on github ?

Any news about it? ๐Ÿ‘

+1
If this feature is supported,pls tell me

+1
Was shocked to find this isn't already a feature... I thought I was doing something wrong at first!

+1, this is missing

How can I know when this gets implemented without receiving a notification every day?

Agreed, please thumb up the issue instead of leaving a +1 and needlessly notifying everyone who subscribes to this.

+1

+1

Ooooh thanks god ! just noticed i'm not the only one who's struggling.

Really liking visual studio code. Wonderful cross platform IDE, but it woefully needs this feature.

Hope this feature won't delay.

Feature has been developed through VS Code Extension already, available at the Market Place : https://marketplace.visualstudio.com/items?itemName=GitHub.vscode-pull-request-github

@julien-conan Are you sure thatโ€™s the right link? This issue is not about GitHub pull requests. Not even about Git merging.

@bradkemper ho ho! I was sure Something was wrongโ€ฆ hello guys :) ^^

@xahon you donโ€™t have any ยซforkยป button ? I mean you either need to now you are sarcastic or trolling or maybe you donโ€™t understand...

If you think the maintainer of this project is to strict on whom can collaborate remember that almost anything one can imagine about VScode can be provided as an extension created by anyone!!! If you can write quality code and submit it it will probably be included in the community effort!!!

+1

we really need this feature ASAP!
๏ผˆๆ•‘ๆ•‘ๅญฉๅญๅง๏ผ‰ o(โ•ฅ๏นโ•ฅ)o

@alexandrudima It's the only feature missing for me to migrate from PHPStorm to Visual Code.
In your opinion: how difficult would it be to implement it? Can we somehow help?

Can we add this feature in the 'Working Tree' view? So you can choose which part to change when you make local changes.

I want to state a distinction that hopefully does not go unnoticed. VSCode already has git merge capabilities that meet my needs. What it lacks is the ability to diff/merge ad-hoc.

Right now I can open two random unrelated files and compare their differences (VSCode already has this) but i cannot merge differences left or right without manually editing the files.

So what I'm looking for is this interface:
image
But add the ability to edit the file on the left (currently it's read-only) and buttons like meld or winmerge that let me chose which side to use and make both files match the chosen side.

It's been 2 years since the OP - anybody still having hopes to see this anytime soon? It's the only thing that keeps me from switching from Atom.

+1

+1

+1

+1

+1

I am frequently examining the diff of two files, and it would be very nice if VSCode supported this functionality. It's annoying to require Meld or vimdiff for whenever I need to selectively copy changes

+1

As mentionned previously, "diff & merge" from Jet Brains IDE works very well.
Would be a much needed feature for resolving conflicts in diff view.

Would also love to see this feature or an extension with this feature!

+1
from me

Please either let me edit the files in the diff view, or allow me to copy changes from one side to the other.

It's better to introduce new design than this useless feature

You can argue that there is a better way to do file compares, but as things are right now, this feature is most definitely not useless.

I'm really surprised this isn't a feature of the compare view. It's probably the most common action to want to perform in that view.

2 years...

I looked into writing an extension to help implement the feature. The biggest hurdle is that there's no way to add a handler for gutter decorators. Sure you can slide in an arrow icon when diffing two files, but there's no way to define behaviour on icon clicks.

It seems very petty to withhold that functionality from the API, given the behaviour already exists in the implementation of breakpoints.

I can't believe this is lacking as a feature. It's the same in Visual Studio! Without the ability to compare and merge changes, having a diff tool is almost pointless.

@deyvidm Just allowing hot-key to move changes is good enough.

  1. It will be nice to support it in the diff window opened by the vscode.commands.executeCommand('vscode.diff')

  2. More advanced. Add an API to get diff details for example, is active line is not exists in the other window, if it partial different, what's the value in the other window, navigation between diffs etc.

This feature is definitely needed. Any update?

I would love this please. Then I don't have to use another tool.

This should be among the most critical tools in the pipeline. There's even no plugin, if there was a vscode extension, it would be awesome.

+1000 Please add this feature!

+1 from me too.
After the great update today with many new features this is highly anticipated ๐Ÿค˜

For the love of ... Argh, I though I was done with still needing use vim for this.

This is no longer blocked by #4180, as that issue is resolved. Will we have any progress on this one?

This issue keeps some members of our team on WebStorm :(
+1

I can't believe this issue still isn't resolved. I keep getting VSCode updates with frivolous changes that I really don't care about (such as tinkering with the colours of the side bar and other features that are nice to have, but really have no effect on my workflow) and yet this really serious omission is still being left fixed.

If VSCode is to really be a contender as a best of breed editor I should be able to perform all my code editing workflow without having to leave it or use other editors. As it stands, I can edit code, I can commit code, I can even see what has changed, but there is no way to do anything with what I can see (in a useful way). I still have to have a seperate editor or diff tool as part of my workflow and this is just crazy!

I know VSCode is free. I know we're at liberty to use any editor we want, but the thing is VSCode really is just about the best code editor (especially for C++) around. The fact it has so many other features built right in makes it a joy to use. Intellisense makes my C++ coding experience about as good as it gets in Visual Studio. The problem is, this one omission spoils a workflow that is, for all intends and purposes, about as close to perfect as we're likely to get in a single editor.

Devs, please, please, please realise the importance of this omission. It's not just an inconvenience, it is a fundamental flaw. The fact there isn't even an extension to provide this feature makes it a serious fundamental flaw. That said, I really would prefer not to use an extension as these rarely have the polish nor integration that a baked in feature would. I assume the devs of VSCode actually use VSCode to develop VSCode, right? How have they not realised just how important this feature (or lack there of) is?

I'm at a point where I feel it may be necessary to dump VSCode and move on to something else. In the past I've tried Atom, but I've heard it's been greatly improved since the last time I tried it. I would be willing to lose the Intellisense (a nice to have) in favour of the ability to perform proper diff/merge tasks (a need to have for any developer). I truly hope the VSCode devs read this post and decide to finally take action on this as I really do not want to have to jump ship at this point.

Thank you.

People... We get it: you have really strong feelings about this issue, as do I. Please upvote the issue as described in the contribution guidelines, but stop with the +1 comments/rants. They aren't used for prioritising and only serve to drown out the actual informative comments.

Your comment isn't going to land on one of the developers' desks and convince them to prioritise this. In fact, it's very likely they don't read the comments at all until after they already decided to start working on it. The only people you're pestering is your peers who already agree with you. That's 83 folks, at the time of writing.

Think before you comment. Thank you.

Well, in all fairness the guidelines state:

make relevant comments and add your reaction

Explaining why this is so important is, IMHO, relevant! It's also nice to know that other people share your frustration. So, whilst I take your point on board, I don't think telling people to stop posting comments/rants is really the way to go. People like to be heard, even if it is only by their peers.

I created an extension to enable compare and merge changes. It still in alpha stage so there are not quite gaps and glitches but I would love to get feedbacks and improve it.

https://marketplace.visualstudio.com/items?itemName=moshfeu.diff-merge
https://github.com/moshfeu/vscode-diff-merge

At the very least, allow us to specify an external command to do the comparison: WinDiff, WinMerge, Meld, etc.

At the very least, allow us to specify an external command to do the comparison: WinDiff, WinMerge, Meld, etc.

There are a couple of extensions to integrate Meld that work well, but don't really fulfill the goal of this feature request:

https://github.com/danielroedl/vsc-meld-diff
https://github.com/Aghabeiki/gitdiffer

This would be an important feature in that select/copy/switch windows, paste, can be difficult to manage when the source and destination is unfamiliar code as in a team situation

You can use WinMerge, which has this feature, but - WinMerge lacks Intellisense, and wont automatically check out the file being modified
This link is a little dated but you get the idea
http://blog.paulbouwer.com/2010/01/31/replace-diffmerge-tool-in-visual-studio-team-system-with-winmerge/

Adding my desperate request for this functionality to be built into VS Code.

People... We get it: you have really strong feelings about this issue, as do I. Please upvote the issue as described in the contribution guidelines, but stop with the +1 comments/rants. They aren't used for prioritising and only serve to drown out the actual informative comments.

Your comment isn't going to land on one of the developers' desks and convince them to prioritise this. In fact, it's very likely they don't read the comments at all until after they already decided to start working on it. The only people you're pestering is your peers who already agree with you. That's 83 folks, at the time of writing.

Think before you comment. Thank you.

+1

+1 :)

For 4 years, officials or 3rd extensions still not fully implement the function as @sigmarising shown. Orz...

It's been over 3 years since this was opened, any news?

Any news on this?

I upvoted this issue because I'm spending a bit of time looking for a solution for this type of workflow and expected others would already have had a solution.

Use Case: I have two files to compare that come from two separate git repositories. Some of the differences are intentional, others need to be reconciled. I mention because some of the diff/merge extensions seem targeted for git history specifically.

Desired features:

  • Selection of Files for Comparison
  • Syntax Highlighting remains in diff view
  • Diff Highlighting of lines added, removed, or changed
  • Side-by-side comparison for viewing both files
  • Jump to Diff (next/previous)
  • Accept / Reject a difference
  • Edit file(s) in diff view
  • Keybindings or shortcuts to make changes, with consideration for MacBook Pro or tenkeyless keyboards without function keys
  • No issues or side-effects

Some alternatives in case its useful for others

Name | Source | Cost | Issues | SyntaxHi | DiffHi | Side-by-Side | Jump to Next | Accept/Reject | Editable | Keybindings
------|---------|-----|-----|------|-----|----|------|-----|----|----
| vimdiff | External | Free | No | โœ”๏ธ | โœ”๏ธ | โœ”๏ธ | โœ”๏ธ | โœ”๏ธ | โœ”๏ธ | โœ”๏ธ | โœ”๏ธ |
| Select for Compare | Built-in | Free | No | โœ”๏ธ | โœ”๏ธ | โœ”๏ธ | โœ”๏ธ | โŒ | โœ”๏ธ | โŒ | โœ”๏ธ |
| Partial Diff | Extension | Free | No | โŒ | โœ”๏ธ | โœ”๏ธ | โœ”๏ธ | โŒ | โŒ | โŒ | โœ”๏ธ |
| Diff & Merge | Extension | Free | Yes | โœ”๏ธ | โœ”๏ธ | โœ”๏ธ | โœ”๏ธ | โœ”๏ธ | โœ”๏ธ | โœ”๏ธ | โŒ |
| Diff | Extension | Free | Yes | โœ”๏ธ | โœ”๏ธ | โœ”๏ธ | โŒ | โŒ | โœ”๏ธ | โŒ |
| JetBrains (WebStorm, etc.) | External | $130 | โ” | โ” | โ” | โ” | โ” | โ” | โ” | โ” |
| Meld | External | Free | โ” | โ” | โ” | โ” | โ” | โ” | โ” | โ” |

For example, I'm defaulting to vimdiff file1 file2 has [c and ]c to jump between changes and dp and do to put or obtain differences from one file or the other to reconcile differences. Doing :syntax off can toggle syntax highlighting colors for easier readability of diff highlighting.

Easy enough but looking for an alternative if it exists to improve my productivity while still using VS Code. The point is to use VS Code as the IDE.

@j12y , I saw you mentioned Diff & Merge has bugs. I'd love to hear more about them, can you please open (an) issue(s)?

Give Webstorm a shot. It's an IDE for power users with features like this, and lots of expected functionality is default, not janky plugins. vscode is lacking in many areas and the performance is also very meh compared to Webstorm.

I upvoted this issue because I'm spending a bit of time looking for a solution for this type of workflow and expected others would already have had a solution.

@j12y I've gone down the identical path. It's hard to believe that something 30 years old is so functionally superior to the current offerings.
You didn't mention any of the Jet Brains offerings. They have an acceptable diff integration:
intellij-diff

A bit off track here but the other things that keeps me tied to vim is the multi-highlight. VCS's similarly named extension does a passable job at it, but not quite the same, even if you can force the same key bindings.

Another one here wishing this simple feature.

VSCode doo doo

Would love to have this feature too :+1:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shanalikhan picture shanalikhan  ยท  3Comments

sirius1024 picture sirius1024  ยท  3Comments

ryan-wong picture ryan-wong  ยท  3Comments

vsccarl picture vsccarl  ยท  3Comments

curtw picture curtw  ยท  3Comments