In this post:

How to compare files with sublime

Native search in Sublime Text 3

Sublime Text has incorporated file comparison - Diff files - which is not easy to be seen at least for Linux and MacOS. In order to make it work you need to follow this steps(steps tested on Sublime 3 and Ubuntu):

  • Go to File
  • Open Folder
  • Navigate to the directory which contains the files to be compared(select this folder)
  • Open
  • Folders sidebar should appear - if you don't see the sidebar you need to go to ( View -> Sidebar - Show Sidebar)
  • In the sidebar select the files for comparison(with pressing CTRL (Linux and Windows) or (on OS X)
  • Diff Files...

Using plugin Compare Side-By-Side

A better and easier way to compare files in Sublime text editor is by using a plugin:

Compare Side-By-Side

Side by Side interface

How to install Compare Side-By-Side(check below how to install package control):

  • Go to Preferences
  • Package control CTRL+SHIFT+P
  • Install Package
  • Search for Compare Side-By-Side
  • Left click with the mouse

In order to compare you need to:

  • Select the first file for comparison to be active
  • Go to the second one with right click of the mouse
  • Compare with active tab

or you can use: Compare with...

In order to remove this plugin:

  • Preferences
  • Package control
  • Remove Package
  • Search for Compare Side-By-Side
  • Left click with the mouse

Install package control

In order to install package control you can visit this page and follow the instructions: Sublime Install package control

Manual installation

  • Preferences
  • Browse Packages…
  • Browse up a folder and then into the Installed Packages/ folder
  • Download Package Control.sublime-package
  • copy the file into the Installed Packages/ directory
  • Restart Sublime Text

or automated:

  • View
  • Show Console
  • Paste this code(for Sublime 3)
import urllib.request,os,hashlib; h = '6f4c264a24d933ce70df5dedcf1dcaee' + 'ebe013ee18cced0ef93d5f746d80ef60'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by) 

Add permanent highlighting for file types

By default all files in Sublime are opened as Plain text. It's rather annoying to open files from some association files and manually select the highlighting. If you know the file type association and the related highlighting then you can set it up in Sublime editor by:

  • View
  • Syntax
  • Open all with current extension as ...
  • Select language - for example HTML ( in my case I have files .hbs which are related to HTML)
  • Left click of the mouse
    e
    Now every time when you open file from this file type you will have this association.

In order to restore the default value you can:

  • View
  • Syntax
  • Open all with current extension as ...
  • Plain text

Search with regular expressions in Sublime Text editor

If you want to perform are regex searches in Sublime you need to enable the regex search by:

Regex Sublime search

  • Find
  • Find - CTRL + F
  • Enable regex search by pressing this button .* (next to Aa from search menu)
  • Enter the Regex expression - for example searching for numbers: \d+
  • Find