By Manny Fernandez

October 21, 2024

Sublime Text Cheat Sheet

This is a work in progress, I will be updating it as I use it more and figure things out.

Syncing with iCloud

Install Sublime Text 4

Run the following command from the command line of your macOS device.

cd ~/Library/Application\ Support/Sublime\ Text/Packages
mkdir -p ~/Library/Mobile\ Documents/com\~apple\~CloudDocs/WebDev/ST/Plugins
mv User ~/Library/Mobile\ Documents/com\~apple\~CloudDocs/WebDev/ST/Plugins
ln -s ~/Library/Mobile\ Documents/com\~apple\~CloudDocs/WebDev/ST/Plugins/User

These commands essentially move your configuration files to a syncable folder in iCloud Drive then sets up a symbolic link to the User folder under Sublime Text’s new folder structure and where the app is expecting the files.

cp -R ~/Library/Application\ Support/Sublime\ Text/Packages/User ~/User

     -R    If source_file designates a directory, cp copies the directory and
           the entire subtree connected at that point.  If the source_file
           ends in a /, the contents of the directory are copied rather than
           the directory itself.  This option also causes symbolic links to be
           copied, rather than indirected through, and for cp to create
           special files rather than copying them as normal files.  Created
           directories have the same mode as the corresponding source
           directory, unmodified by the process’ umask.

           In -R mode, cp will continue copying even if errors are detected.

On the other Macs you want to sync with, run these commands.  This will mirror the macOS device from the above steps

cd ~/Library/Application\ Support/Sublime\ Text/Packages
rm -rf User
ln -s ~/Library/Mobile\ Documents/com\~apple\~CloudDocs/WebDev/ST/Plugins/User

     -R    Attempt to remove the file hierarchy rooted in each file argument.  The -R option implies the -d option.  If the -i option is specified, the user is prompted for

             confirmation before each directory’s contents are processed (as well as before the attempt is made to remove the directory).  If the user does not respond

             affirmatively, the file hierarchy rooted in that directory is skipped.

     -r      Equivalent to -R.

     -f      Attempt to remove the files without prompting for confirmation, regardless of the file’s permissions.  If the file  does not exist, do not display a diagnostic message

             or modify the exit status to reflect an error.  The -f option overrides any previous -i options.

Commands

⌘ ⌥  F  (Command Option F) – Find and Replace – Ensure regex is selected on the left.  If needed, match Case

Highlight the word and ⌘ D  (Command D) continue to hit same command to manually select the matches to select all instances ⌘ ^ G (Command Control G) will select all instances without having to select one-by-one

(Command) and double-clicking word is a multi-select

Tabs

⌘ ⌥   ← or   (command option right/left arrow) use the arrows to scroll through tab’d file

⌘ ⇧ and W (command shift W) to close selected tab

⇧ ⌘ T  (command shift) to re-open a closed tab

⇧ ⌘ ⌥ 2-4 (shift command option 2-4) to open additional panels (side-by-side files)

⇧ ⌘ ⌥ 5 (shift command option 5) will Tile the panels

⌘ ⌥ 2 (command option 2) to stack panels

^ ⌘ ↑ ↓ (control command up/down arrow) to move the selected line up and down

⌘ B (Command B) to run the code inside sublime text

⌘ K (Command K) and B (holding ⌘) to open the sidebar

⌘ / (Command forward slash) will comment our the lines based on the

⌘ ⇧ P (Command Shift P) to open the common pallet

⌘ X (Command X) to delete entire line

Macros

^ Q (Control Q) to start recording macro

Search and Replace

Perform a Find All, then ^ F2 (Control F2) and each of the selection regions will get added as a bookmark.

^ ⌘ G (Control Command G)  while choosing the character you are looking for  ⌘ L (Command L) to choose the entire line, then delete

 

Recent posts