Comparing the contents of two files in Sublime Text, with a side by side view - sublimetext3

I have already read Comparing the contents of two files in Sublime Text but the answers (either the native "Folders > Diff files" feature, or using FileDiffs) show the differences between 2 files like with the diff tool, which I don't want:
--- file1.py
+++ file2.py
## -1,21 +1,19 ##
-import os
+import os, sys
import numpy as np
-print('hello')
+print('hello world')
-import sys
Instead, I would like a side-by-side comparison like this with PSPad native diff tool:
How to achieve this side-by-side comparison between two opened files in Sublime Text (2 or 3)?
Is it possible natively with Sublime Text?

Installation for Windows and Linux:
Press CTRL + SHIFT + P
Type Package Control: Install Package
Press ENTER
Type Compare Side
Select package named Compare Side-By-Side
How to use?
Select one tab which you want to compare
Right Mouse Button on second tab which you want to compare
Select Compare with active tab
How it looks?

Yes, you can do this without plugins. First, select View → Layout → Columns: 2
making your window look like this
Then, drag your desired tab over to the other pane
and you should be all set.

Related

Spell check with CAPS using Sublime Text

I’ve noticed that Sublime Text 3 seems to ignore CAPITALISED words when using the spell checker.
Quite a lot of my document has strings in caps. I don’t want to mess with the formatting, just check the spelling.
Is there a file I can modify to toggle spell check where capitals are involved in SublimeText3?
I realise this may get thrown out for not being a coding question but I'll show you a Venn diagram of those who use SO and those who know how to really use Sublime Text.
The answer is yes, you can spell-check words in all caps, but it's going to take some effort. There is a setting that is appropriate here:
// Word list to use for spell checking. May also be a list of dictionaries.
"dictionary": "Packages/Language - English/en_US.dic",
The included dictionaries (there is one for en_US and one for en_GB) include some words in all caps, such as AIDS and DNA, but not all, so you'll need to make your own .dic file. Fortunately, this is fairly straightforward. You'll need to extract the original file, convert it to upper case in Sublime, save it, then change your settings to point to both dictionaries.
To extract the dictionary package, install PackageResourceViewer from Package Control. Open the Command Palette with CtrlShiftP (⌘ShiftP on macOS), type in prv, make sure PackageResourceViewer: Extract Package is selected, and hit Enter. Next, select the Language - English package, hit Enter, then hit Enter again when it shows Start Extraction (1 of XX items selected). A little popup should come up telling you the package was extracted successfully.
Next, you'll need to navigate to the correct folder and open the dictionary file in Sublime. Select Preferences → Browse Packages… (macOS: :Sublime Text → Preferences → Browse Packages…) to open the Packages directory in your file manager:
Linux: ~/.config/sublime-text-3/Packages or ~/.config/sublime-text/Packages
macOS/OS X: ~/Library/Application Support/Sublime Text 3/Packages or ~/Library/Application Support/Sublime Text/Packages
Windows Regular Install: C:\Users\YourUserName\AppData\Roaming\Sublime Text 3\Packages or C:\Users\YourUserName\AppData\Roaming\Sublime Text\Packages
Windows Portable Install: InstallationFolder\Sublime Text 3\Data\Packages or InstallationFolder\Sublime Text\Data\Packages
The exact path depends on version and whether or not you upgraded from Sublime Text 3.
Once in Packages, navigate into the Language - English directory and open either en_US.dic or en_GB.dic (depending on your locale and preference) in Sublime. Hit CtrlA (macOS: ⌘A) to Select All. Next, select Edit → Convert Case → Upper Case and all letters will be capitalized. Finally, select File → Save As…. Navigate up one level from Language - English to Packages, then go into the User directory and save the file there as en_US_CAPS.dic or en_GB_CAPS.dic, depending on which original you opened.
Finally, select Preferences → Settings and add the following to your user settings on the right side:
"dictionary": ["Packages/Language - English/en_US.dic", "Packages/User/en_US_CAPS.dic"],
Change both occurrences of US to GB if that's what you're using. Save, and you should be all set.
If you want to clean up a little at the end, you can delete the Packages/Language - English folder that was created earlier, but things should be just fine if you don't.

Is it possible to split windows without showing tabs in the middle?

If I split the IDE into 2 sides, the tab list is duplicated. Is there any way to hide the one in the middle of the screen, to save space and make it easier to compare the 2 files?
Sure. I can see a few possible options actually.
1. Use more appropriate Compare Files functionality: look for Compare with... action in the context menu.
For example:
Locate and select 2 files in the Project View, use context menu and choose Compare Files action.
... or select one file and use Compare with... -- now point to the 2nd file via file chooser dialog.
... or copy contents of one of the files into the Clipboard and then use Compare with Clipboard... in your Editor context menu (currently opened file).
NOTE: You can edit/merge files in Differences Viewer screen; when you exit it the changes will remain until auto-save or manual Save is called.
2. Do not display list of the opened tabs on the right side: put it at the top/bottom or temporarily hide it completely (until you are done with your comparing task).
You can change the tabs position quickly at any time via Help | Find Action... (or Search Everywhere via Shift + Shift) and search for tab placement -- it can then be changed right from there without the need to go into the Settings/Preferences screen (use the appropriate ON/OFF toggle).

Empty diff window with Apply Patch in TortoiseSVN

Steps:
Use TortoiseSVN's context menu to select "Create Patch"
On another machine do the same but select "Apply Patch" and select the file generated in step 1.
A blank merge window is opened.
It looks like this:
The patch file is valid and I can use unix patch to apply it successfully (with some line-ending tinkering).
I'm on Windows 10 and TortoiseSVN/TortoiseMerge 1.9.5
The problem was that TortoiseMerge was maximized. There's a floating window on the left.
Unmaximize the TortoiseMerge window and you can see the file selector window. You can select files in that window to see them in the diff view and there's buttons for applying the patch.
It should look like this:
I had the same problem and had to select TortoiseMerge for Settings > Diff Viewer > Merge Tool.
I previously configured an external editor here and then it did not show this patch window but only an empty merge tool. Maybe this feature does not work very well with external editors.

Is there a way to use Sublime to show file previews in Windows Explorer for certain files?

I'd like to be able to preview all plain-text files in the Windows File Explorer Preview Pane. To illustrate, here's what sublime files currently look like:
As you can see, Context.sublime-menu is highlighted, but a preview doesn't appear. They're just plain-text files though - you can open them in Notepad. Is there a way to tell windows "Use notepad (or sublime) to view this type of file the preview pane"?
Thanks to #KeithHall's link - while it didn't work for me - got me started on a pretty long path to finally figuring this out. And finding a better solution than I thought existed.
In short, simply install the Delphi Preview Handler. Which pretty much gives you an IDE in the preview pane. It's pretty simple to use and just awesome.
After installation, if you click on a .js file in Windows File Explorer you can immediately see a different preview pane.
Registering Other Extensions
The Preview Handler doesn't compensate for all plain-text files unfortunately, so you're gonna have to manually add the sublime extensions and any other extensions in the Registry Editor.
Here's the bird's-eye view of this process:
Find the key/value that instructs Windows to use Delphi as the preview handler for .js files.
Copy the key/value
Apply that to each extension you want to preview.
Here's more in-depth instructions:
First, you need to find the ID of the Preview Handler, and its Default Value
win + rregedit > expand HKEY_CLASSES_ROOT
Find .js and expand it.
.js should have a subkey named shellex, expand that
You need to recreate this shellex key for each extension you want to add, so copy its contents:
shellex should have a sub-key named with a bunch of numbers, letters, and dashes, this is the ID of the preview pane (I think)
Right-Click that > Rename > Copy > Cancel
Open Sublime > Create a new file > Paste
Go back to the Registry Editor, Click that ID subkey, and a String value called (Default) should appear in the right side of the window.
Double-Click that
Copy > Cancel > Paste in sublime. This is the ID of the Preview Handler (I think).
At this point there should be 2 IDs in the sublime file.
Now You're ready to add these same values to other extensions.
Find the extension(s) you want to change. For me it was all the sublime file-types.
Right-click > New > Key > call it shellex
Go to sublime, copy the first value
Right-click shellex > New > Key > Paste
Go to sublime, copy the second value
Click the new key and make it's default value that 2nd id.
So it should look similar to this:
v .sublime-commands
| v shellex
| |- {823BD1D4-...
And in the right side of the window:
Name Type Data
(Default) REG_SZ {AD9955...
Sources:
This Answer by #rxantos pointed me in the direction of the Delphi Preview Handler.
I spent about an hour looking for this app but never found it.
This Answer by #tvj247 is perhaps a more simple solution, but my HKey structure didn't match his (I'm using Windows 10).
And as for fiddling with the Registry, that was trial, error, and comparing sublime extension keys to js, html and css.

How to open Sublime Text files in window based on extension?

Is there any way to get Sublime to open all files of a certain extension in the same window? For example, when using a 2x2 grid, I'd like to keep all SCSS files in the upper left, all HAML in upper right, JS lower left and search in lower right. I'd like to use the search function, and have files go to the other three tabs instead of the search window each time.
I've tried the 'open in relevant window' plugin and it doesn't appear to make any difference.
When opening lots of files it gets very tedious opening them and having to manually move them to a window that wasn't active when opening.
Edit: I'm working on a Mac, so I'd need something that works there, or preferably cross platform.
Edit: Op is working on a Mac, I'll leave this in case any windows users are interested in this solution.
---
Perhaps an extra shell extension would help.
If you're familiar with the Registry, you can create a new key that opens all selected files in a new window. Simply create a modified version of what Sublime Text already has.
The existing key for Sublime Text exists here:
HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text\command
With the default value of (depending on version):
C:\Program Files\Sublime Text 3\sublime_text.exe "%1"
You could create a new key like so:
HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text (new window)\command
Then add the -n arguement to the default value:
C:\Program Files\Sublime Text 3\sublime_text.exe -n "%1"
This will create a new window every time you use the shell extension to open files and will keep multiple files organized in the same window.
To take this a step further, if you have any programming experience you could create your own shell extension which takes a list of files and groups them for you, which then in turn can create the new windows programmatically.

Resources