I have two cloned repositories of two very similar open-source projects, which I have been working on in different instances in Sublime Text 2 to arrive at my desired result. Code from both of these projects was used. I have been using Git as version control for my project, but have not included the original projects. Thus, I would like to be able to quickly compare the contents of two files of the original project and compare the differences between them and my project.
I was hoping that Sublime Text 2 would have a "Compare File" feature, but I can't seem to find anything related to it in the settings or online. A third-party ST2 package to accomplish this task would also work well. Is such a task possible to do within the ST2 text editor?
You can actually compare files natively right in Sublime Text.
Navigate to the folder containing them through Open Folder... or
in a project
Select the two files (ie, by holding Ctrl on
Windows or ⌘ on macOS) you want to compare in the sidebar
Right click and select the Diff files... option.
Compare Side-By-Side looks like the most convenient to me though it's not the most popular:
UPD: I need to add that this plugin can freeze ST while comparing big files. It is certainly not the best decision if you are going to compare large texts.
There are a number of diff plugins available via Package Control. I've used Sublimerge Pro, which worked well enough, but it's a commercial product (with an unlimited trial period) and closed-source, so you can't tweak it if you want to change something, or just look at its internals. FileDiffs is quite popular, judging by the number of installs, so you might want to try that one out.
UPDATE (Given the upvotes, I feel there is a need for a complete step-by-step explanation...)
In the Menu bar click on File->Open Folder...
Select a folder (the actual folder does not really matter, this step is just to make the FOLDERS sidebar available)
If there is no Side Bar shown yet, make it appear via View -> Side Bar -> Show Side Bar
Use this FOLDERS-titled Side Bar to navigate to the first file you want to compare.
Select it (click on it), hold down ctrl and select the second file.
Having two files selected, right click on one of the two and select Diff Files...
There should be a new Tab now showing the comparison.
Original short answer:
Note that:
The "Diff files" only appears with the "folders" sidebar (to open a folder: File->Open Folder) , not with "open files" sidebar.
UPDATE JAN 2018 - especially for Sublime/Mac
(This is very similar to Marty F's reply, but addresses some issues from previous responses, combines several different suggestions and discusses the critical distinction that gave me problems at first.)
I'm using Sublime Text 3 (build 3143) on Mac and have been trying for about 30 minutes to find this File Compare feature. I had used it before on Sublime/Mac without any problems, but this time, it was trickier. But, I finally figured it out.
The file format does not need to be UTF-8. I have successfully compared files that are UTF-8, ISO-8559-1, and Windows-1252.
There is no File > Open Folders on Sublime/Mac. Many instructions above start with "Select File > Open Folders," but that doesn't exist on Sublime/Mac.
File compare works on a Project basis. If you want to compare two files, they must be saved to disk and part of the current project.
Ways to open a project
If Sublime/Mac is not running or if it's running but no windows are open, drag a folder onto the Sublime app.
If Sublime/Mac is running, select "File > Open", navigate to the desired folder, don't select a file or folder and click "Open".
Add a folder to a project. If the files you want to compare are not part of the same hierarchy, first open the folder containing one of the files. Then, select "Project > Add Folder to Project", navigate to the folder you want and click "Open". You will now see two root-level folders in your sidebar.
The Sidebar must be visible. You can either "View > Side Bar > Show Side Bar" or use the shortcut, Command-K, Command-B.
Files must be closed (ie, saved) to compare. Single-clicking a file in the Side Bar does not open the file, but it does display it. You can tell if a file is open if it's listed in the "Open Files" section at the top of the Side Bar. Double-clicking a file or making a modification to a file will automatically change a file's status to "Open". In this case, be sure to close it before trying to compare.
Select files from the folder hierarchy. Standard Mac shorcut here, (single) click the first file, then Command-click the second file. When you select the first file, you'll see its contents, but it's not open. Then, when you Command-click the second file, you'll see its contents, but again, neither are open. You'll notice only one tab in the editing panel.
Control-click is not the same as right-click. This was the one that got me. I use my trackpad and often resort to Control-click as a right-click or secondary-click. This does not work for me. However, since I configured my trackpad in System Preferences to use the bottom-right corner of my trackpad as a right-click, that worked, displaying the contextual menu, with "Delete", "Reveal in Finder", and.... "Diff Files..."
Voilà!
UPDATE OCTOBER 2017
I never knew this feature existed in Sublime Text, but the interface appears to have changed slightly from the previous answer - at least on OS X. Here are the detailed steps I followed:
In the Menu Bar click File -> Open...
Navigate to the FOLDER that contains the files to be compared and with the FOLDER selected, click the Open button, this makes the FOLDERS sidebar appear
In the FOLDERS sidebar, click on the first file to be compared
Hold the Ctrl on Windows or ⌘ on OS X, and click the second file
With both files selected, right click on one and select Diff Files...
This opens a new tab showing the comparison. The first file in red, the second in green.
View - Layout and View - Groups will do in latest Sublime 3
eg:
Shift+Alt+2 --> creates 2 columns
Ctrl+2 --> move selected file to column 2
This is for side by side comparison.
For actual diff, there is the diff function other already mentioned.
Unfortunately, I can't find a way to make columns scroll at the same time, which would be a nice feature.
The Diff Option only appears if the files are in a folder that is part of a Project.
Than you can actually compare files natively right in Sublime Text.
Navigate to the folder containing them through Open Folder... or in a project
Select the two files (ie, by holding Ctrl on Windows or ⌘ on macOS) you want to compare in the sidebar
Right click and select the Diff files... option.
No one is talking about Linux but all above answers will work. Just use Ctrl to select more than one file. If you are looking to compare side by side, Meld is lovely.
There's a BeyondCompare plugin as well. It opens the 2 files in a BeyondCompare window. Pretty convenient to open files from the sublime window.
You will need BC3 installation present in the system.
After installing the plugin, you will have to provide the path to the installation.
Example:
{
//Define a custom path to beyond compare
"beyond_compare_path": "G:/Softwares/Beyond Compare 3/BCompare.exe"
}
Related
I have been writing code in codelite for c++ since past 20 days, today morning while writing code, by mistake i clicked somewhere and the top menu of options and side menu of projects vanished. I tried many things but i couldnt get them back. I am not a technical person and learning c++ from a tutorial. Now my codelite page is blank and i am stuck. I have unistalled and installed again but when i opened it, it still shows the blank page . I dont know what to do. Is there any history i need to delete from my laptop(for reinstallation) or need to do something in codelite , to get back default codelite page which comes when newly installed.Please help.
might be a little late here but I think I had your problem, if someone encounters similar
Double check what "perspective" you are on
Ctrl + M key can minimize several open views such as the "workspace view" and the "debugger view"
It's pretty simple, this happened to me too. It happens just because you are on full screen mode, and because you are currently in the workspace folder in which your source code is. Just follow these:
press Alt+M to you exit full screen mode. You should now be
able to view the top menu.
now go to view in the top menu and click on the Workspace pane.
After the Workspace pane appears, you will notice that you are now
in the workspace folder rather than on the source code file. Now, to go
to the file, click on the workspace on which your file is, click on
the project name under which your source code is, click on src,
then click on the file, e.g. main.cpp
Post your doubts if you still have any
I'm new to rc files and I'm used to being able to close files in VS and be prompted to save or not save. This way I can quickly undo changes I've made to the file. How do I get similar functionality for rc files?
Thanks.
You can't! This is just one of the many infuriating things about both RC files and VS.
The only easy way I have found is to close the solution, discard the changes, and open the solution again.
I've got into the habit of editing resource files in a text editor most of the time. That saves a lot of pain. I also use Git, so it's often quite easy to revert any unstaged changes or cherry-pick those that I want to keep. The bonus is when I modify the resource this way, VS will detect it and prompt me to reload the file, discarding any changes.
I found one tricky workaround to do what you asked for without solution reloading.
Ctrl+Shift+F to open find dialog.
In the "Find what" field, type any text which should preset in the resource-file (for example, ID of some control).
Along with other files, records corresponding to your resource-file should be appeared in search results.
Double-click on any of this records. If the resource-file was opened (exactly as a resource file) at this stage, VS will inform you about this and ask you what to do: to close other editor or to leave all as it's. The first option is our goal.
When I do a global search/replace in a project, Sublime will automatically open all the files involved, and not save them. I then have to manually save every single file.
Is there a way to have Sublime automatically save all the changes that have been done, and not open the files that where not previously open?
Thanks in advance for anyone who can help me with this.
http://www.sublimetext.com/forum/viewtopic.php?f=3&p=40348
I think it's Option + Command + S(Mac) or Command + Alt + S(Win).
Just performed a similar task with the free Visual Studio Code. Replace in Files without opening files and fast. Just made 60k changes in just a few minutes.
Robust if awkward.
While it doesn't change the fact that Sublime Text doesn't seem to be the best tool for this job, here's a practical workaround procedure I've come to rely on. It's reasonably slow but painless if done correctly. Memory consumption impact seems negligible, if you're wondering. The ballpark of my use cases is up to about 10k files in up to a handful of minutes on a mediocre memory-cramped machine using Sublime Text 3.2.2 (3211) on Windows 10 Pro x64.
Requirements
You'll need the package SideBarEnhancements to be installed.
…which in turn relies on Sublime Text 3 or newer as of writing this.
Procedure
(Could probably be deferred until step 3.) You add the directory A that you're going to operate on to the project sidebar.
You initiate your batch replacement operation over numerous files inside directory A.
Sublime Text takes its time to open numerous tabs belonging to directory A recursively and perform replacement in each.
You right-click on the directory A in the project sidebar to bring up its context menu and choose "Save Views".
Sublime Text takes its time to save each tab belonging to directory A recursively.
You right-click on the directory A in the project sidebar to bring up its context menu and choose "Close Views".
Sublime Text takes its time to close all tabs belonging to directory A recursively.
Disclaimers
Warning
Do not make the mistake of skipping step 3 or you'll effectively become stuck in a GUI loop of writing confirmation dialogs defaulting to "Yes" for however many thousands of files you're operating on.
If you decide to abort operation between steps 2 and 3 — your best course of action, is to back the files up on disk, proceed with the outlined procedure and then restore the backup.
Caution
All of the tabs belonging to the directory you'll operate on will be closed by the end of this procedure. If you need a substantial portion of them to remain open throughout replacement — consider organizing the files contained into a sub-directory structure conducive to cherry-picking.
General advice
As a rule of thumb, before proceeding with this procedure, it would be wise to check if the required context menu entries are in fact present (greyed out or not) in your combination of editor+package versions. And to be on the safe side, you might want to back up your data and Sublime Text session before massive operations.
I like to browse through my C++ projects in Notepad++. I use the SourceCookifier Plugin in order to easily jump in between definitions on large files. However, if I load a large C++ header file (around 30.000 lines), with a lot of #define and typedef declarations inside, it seems to hang and takes a long of time to load.
Does anyone know if there is any option one can set to make it faster or can this plugin generally not load so many definitions?
You can accelerate everything by throwing your project folder into the SourceCookifier panel while (and this is the important but badly documented part) pressing a modifier key (shift, ctrl or alt).
.. for importing INCLUDE files. But you have to additionally either
press the CTRL, SHIFT or ALT key while dropping a file or folder into
the treeview.
Or even smarter... separately only add your large define/typedef sources like described. It will result in a performance boost, since their symbols won't be listed in the tree view anymore, but SourceCookifier will still navigate you there, when hitting "Go To Definition" on one of their symbols somewhere else in the project.
I also sometimes use to add header files with several thousand defines to a SourceCookifier session. Without pressing ctrl-key it takes up to 5 mins per file, but with pressing ctrl-key it only takes 1 second!
EDIT/
Adding source files without pressing ctrl-key:
"Go To Definition" functionality? Yes.
Symbols shown in tree view as subnodes of source file node? Yes.
==> Not recommended for laaaarge source files.
Adding source files with pressing ctrl-key:
"Go To Definition" functionality? Yes.
Symbols shown in tree view as subnodes of source file node? NO.
==> Recommended for laaaarge source files.
Clicking on "my computer" in the start menu returns a GUID link instead of a direct link. For example:
::{20B04FE1-3AEA-1069-A2D8-08012B30309D}
How can I convert it to a normal path so that I can get a list of directories and files with the help of QDir?
UPDATE
I'm not trying to get a list of drives. It is easily done with Qt. I just want to know that a user clicked My Computer in the start menu. (My application can replace Windows Explorer).
You are looking there at an item in the Shell Namespace, not in the filesystem.
Introduction to the Shell Namespace:
http://msdn.microsoft.com/en-us/library/windows/desktop/cc144090(v=vs.85).aspx
The shell shows many things which don't exist as files, My Computer being one. The Desktop is another - the shell desktop is a merged view of the All Users desktop folder, your personal desktop folder, and a few other items which are purely virtual like the recycle bin.
To find out more about the item you can use SHParseDisplayName to convert a name to an ITEMIDLIST.
If you intend to offer a replacement for Explorer, good luck!