Skip to content

Latest commit

 

History

History
409 lines (360 loc) · 17.8 KB

sublime_all.md

File metadata and controls

409 lines (360 loc) · 17.8 KB

Sublime Text 4

About

This is a editor cum IDE used for any format of file.

Website - https://www.sublimetext.com/

System (described here): Windows 10

Documentation

link - http://docs.sublimetext.info/en/latest/index.html

Installation

Win

I prefer using Win 10. So, install on Win 10 & then connect WSL by creating shortcut to the ubuntu repo "/usr/local/bin/subl"

Follow the steps:

  1. Install from here
  2. make the shortcut link on ubuntu using sudo ln -s "/mnt/f/Softwares/Sublime Text 3/subl.exe" /usr/local/bin/subl
  3. use subl on bash-cmd

Mac

  1. Install from here
  2. Use subl from terminal by adding the bin folder to the PATH environment variable a. echo 'export PATH="/Applications/Sublime Text.app/Contents/SharedSupport/bin:$PATH"' >> ~/.zprofile b. Use subl <filename> on terminal & it will open in the editor.

Linux

Follow the commands below: Source

# Download and install GPG Key
$ wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add -

# Enable Sublime Text repository
$ echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list

# Install Sublime Text 4 on Ubuntu 20.04
$ sudo apt update
$ sudo apt install sublime-text

And then open ST4 from the "Applications" at start menu.

Uninstallation

Win

  • All the extra packages are installed in "click Browse Packages".
  • So, during uninstall, make a copy of the Sublime Text3 in other drives (E/ F/ G). Location - "C:\Users\abhijit\AppData\Roaming\Sublime Text 3".
  • After re-install, copy the folder into the location of the 'Browse Packages'

Sublime Merge

A Git Client

Context Menu

NOTE: DON'T Forget to tick the option.

If missed, follow this workaround below:

  • Create a .bat file with ST3.
  • Copy and Paste this code:
@echo off
SET st3Path=C:\Program Files\Sublime Text 3\sublime_text.exe
 
rem add it for all file types
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3"         /t REG_SZ /v "" /d "Open with Sublime Text 3"   /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3"         /t REG_EXPAND_SZ /v "Icon" /d "%st3Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3\command" /t REG_SZ /v "" /d "%st3Path% \"%%1\"" /f
 
rem add it for folders
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 3"         /t REG_SZ /v "" /d "Open with Sublime Text 3"   /f
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 3"         /t REG_EXPAND_SZ /v "Icon" /d "%st3Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 3\command" /t REG_SZ /v "" /d "%st3Path% \"%%1\"" /f
pause
  • Now, "Run as Administrator"
  • DONE!

Shortcuts

  • CMD:
    In cmd, bash-cmd, use subl -h to show the docs.
    • subl -n hello.cpp: opens a file in new ST3 window.

Preferences

  • Preferences -> Settings - Default/User: for all files
  • Preferences -> Settings - Syntax Specific: for that language. E.g. - Python.sublime-settings
  • Convert tabs to spaces: set this
    "tab_size": 4,
    "translate_tabs_to_spaces": false,
  • "Settings": set
{
  "line_padding_top": 1,
  "line_padding_bottom": 1
}
  • ctrl+P - Type
    • @ to jump to symbols,
    • # to search within the file, and
    • : to go to a line number

Packages

Just ctrl + shift + p and type the package name and enter. It will install thereafter. If not found, then manually download the .zip file into the directory "Preferences >> Browse packages". Then restart the sublime App.

  • A File Icon - https://github.com/ihodev/a-file-icon
  • Anaconda
  • AppendSemiColon: On windows, ctrl + ; for inserting semicolon and ctrl + shift + ; to insert both semicolon and newline.
  • Auto Refresh
  • AutoFileName
  • C++ Snippets
  • CMake
  • CMakeEditor
  • CMakeSnippets
  • Color Schemes & Themes
    • Dark
      • Color scheme: Monokai (installed by default)
      • Theme: Default
    • Light (adjust the brightness of the screen to 50 (contrast, brightness))
      • Color scheme:
        • one-light
          1. Download zip from here
          2. Select "Preferences" >> "Browse Packages..." >> "extract the zip folder here as 'one-master'"
          3. In ST, "Preferences" >> "Select Color Scheme" >> "Select One Light"
          4. Done!
        • [ ]sixteen light
        • [ ]ayu-light (Install ayu)
      • Theme: Adaptive
  • Comment-Snippets
  • Conda
  • CppFastOlympicCoding - compile in a unique way (in the sidebar on right side using unique test cases). Demo on the package link. Use ctrl + alt + b to debug, compile, test.

    NOTE: It will work only if the g++ installation is done.

  • DoxyDoc: C++ description about any method, class, template. Usages in animation form.
  • EasyWorkspace - link
    Save Workspace    | ctrl+alt+s       | Save open files and folders as an easy workspace
    Save As Workspace | ctrl+alt+shift+s | Save easy workspace to specified file
    Open Workspace    | ctrl+alt+o       | Open an existing workspace
    
  • Ethereum
    • Enable by using "View >> Syntax >> Ethereum >> Solidity" on .sol file.
  • FuzzyFileNav
  • FuzzyFilePath
  • Git Savvy - Full git and GitHub integration with ST3.
  • Include Autocomplete - for C++ files (in particular) to find out files inside folders. e.g. inside #include " ", use ../ to search for files and also other files inside different folders. NOTE: It has to be applied in workspace i.e. open a folder and import any files within a sub-folder using the above technique.
  • Javascript Completions
  • Kite: Download, kite for sublime, Configuring the Sublime Text plugin, Using the Sublime Text plugin, Disable Anaconda & then activate Kite
    • To disable Anaconda's autocompletions and signatures, click on Preferences → Package Settings → Anaconda → Settings - User. In the opened settings file, add the following configurations:
{
  "disable_anaconda_completion": true,
  "display_signatures": false
} 
  • MarkdownLivePreview: In the command palette, type "markdownlivepreview" and go to markdownlivepreview.preferences and toggle "keep on preview" as true.
  • MarkdownPreview. After install, for key binding i.e shortcut key, Preferences >> Key Bindings, add this line { "keys": ["alt+m"], "command": "markdown_preview", "args": {"target": "browser", "parser":"markdown"} }, on Win or { "keys": ["alt+m"], "command": "markdown_preview", "args": {"target": "browser", "parser":"markdown"} }, on MacOS. Now, press alt+m (Win) or option+m (Mac) to preview in browser.
  • MarkdownTOC
  • MarkdownWriter
  • PlainTasks
  • RTagsComplete
  • SideBarEnhancements
  • Solidity Docstring Generator
    • Enable via "ctrl+shift+p >> type "Generate..." >> Click on it"
  • Stackoverflow Snippets
  • Stackoverflow Debug Helper
  • SublimeLinter: link The code linting framework for Sublime Text 3 (for all languages)
  • SublimeLinter-gcc: link This linter plugin for SublimeLinter provides an interface to gcc or other gcc-like (cross-)compiler.
  • TabNine: A Deep learning based package for autocompletion of code. More
  • Terminal: open terminal at the current folder of the opened file. Access by right clicking and choose the option "Open terminal here". By default it opens the Windows cmd. But to open the bash cmd, follow this: Preferences >> Package Settings >> Terminal >> Settings-Default. And then
    Linux (Ubuntu): add this "terminal": "C:/Windows/System32/bash.exe", i.e. bash executable location.
    Windows: Just add this "terminal": "C:\\Windows\\System32\\cmd.exe", i.e. cmd executable location.
  • Theme - Primer (A UI + syntax theme for @SublimeText inspired by GitHub's UI.): Package control url
  • Toggle Read-Only
  • Translate - downloaded from here and extracted to (..Roaming\Sublime Text 3\Packages)
    ctrl+alt+g - Select text and use this key shortcut.
  • Typescript Syntax
  • Vue Syntax Highlight
  • Vuejs Complete Package
  • WebAssembly Text Syntax
  • Markdown Extended
  • JSON Comma
  • Ethereum
  • EthereumSoliditySnippets
  • Rainglow theme

Shortcut keys

Windows

After the above packages are installed, use the following personalized shortcut keys:

  • ctrl + o - open files, folders.
  • ctrl + s - save the file.
  • ctrl + shift + s - "save as" the file.
  • ctrl + tab - switch b/w tabs in a panel.
  • ctrl + p - find anything within the workspace.
    • eosio.hpp:5 - this takes to line 5 of "eosio.hpp" file.
  • ctrl + shift + p - command palette i.e. manually install packages, Project:Save, Project:close, set:java, set:javascript, so on and so forth.
  • 'Double click' will open the file (among the open side bar) and show in the "OPEN FILES".
    'Single click' will just open the file.
  • alt + shift + 1 - view layout single.
  • alt + shift + 2 - view layout double. Like this, so on and so forth.
  • ctrl + 1 - switch to panel 1.
  • ctrl + 2 - switch to panel 2.
  • ctrl + alt + s - save the workspace with opened folder.
  • ctrl + alt + o - open the saved workspaces (all will appear in the palette).
  • ctrl + shift + p - open the command palette.
  • ctrl + p - open any files from the workspace (chosen folder).
  • ctrl + shift + p >> "install package" --> install any package available.
  • ctrl + alt + b - debug, compile, test C++ program. [NOTE: cppfastcoding package should be installed first.]
  • ctrl + shift + t - open terminal in that directory location, provided all the above (ticked) packages are installed.
  • ctrl + g - Go to a line number.
  • ctrl + shift + k - Delete current line
  • ctrl + r - lists all functions and classes within a file to make them easier to find. Simply start typing the one you want.

For more, click here

MacOS

After the above packages are installed, use the following personalized shortcut keys:

  • Follow this
  • cmd + enter: go to new/next line
  • Enable Mouse Wheel Zoom:
    1. Open Preferences >> Browse Packages >> opens the directory in the Finder
    2. Create a Default (OSX).sublime-mousemap file in location "~/Library/Application Support/Sublime Text 3/Packages/User"
    3. Paste this:
[
    { "button": "scroll_down", "modifiers": ["super"], "command": "decrease_font_size" },
    { "button": "scroll_up", "modifiers": ["super"], "command": "increase_font_size" }
]

Custom

Key Bindings

[
	{ "keys": ["ctrl+t"], "command": "new_file" },
	{ "keys": ["alt+m"], "command": "markdown_preview", "args": {"target": "browser", "parser":"markdown"} },
	{ "keys": ["ctrl+shift+o"], "command": "prompt_open_folder" },	
	{ "keys": ["ctrl+alt+e"], "command": "open_dir", "args": {"dir": "$file_path", "file": "$file_name"} }
]

Snippet

Anytime, a custom snippet might be needed in order to automate a lot of code.

Follow these steps:

  • Open a new snippet - Tools >> Developer >> New Snippet
  • For meaning of each tag, refer video, article, examples.
  • I created my own version. E.g.
<snippet>
	<description>eosc - CONTRACT</description>
	<content><![CDATA[
CONTRACT ${1:/*class_name*/} : public eosio::contract {
public:
	using contract::contract;
	${1}( name self ) : contract(self) {}

private:

};
]]></content>
	<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
	<tabTrigger>eosc</tabTrigger>
	<!-- Optional: Set a scope to limit where the snippet will trigger -->
	<scope>source.c++</scope>
</snippet>
  • This is how, one can create any snippet as per the need.

Build System

Create your custom build file to compile any type of program files.

Follow these steps:

  • Tools >> Build System >> New Build System
  • ctrl + s to save the file in "../Packages/User/" location with a name (to be seen in Build System list).
  • Now, it is visible in Tools >> Build System location.

NOTE: Remember, for any windows based build, the command has to be installed in Win environment. And the same is applied in case of Ubuntu & OSX machine.

  • Cases:

    • windows:
      An object of options to use when the build system is being executed on a Windows machine. Example: { "cmd": ["my_command.exe", "/D", "$file"] }
    • osx:
      An object of options to use when the build system is being executed on a Mac machine. Example: { "cmd": ["/Applications/MyProgram.app/Contents/MacOS/my_command", "-d", "$file"] }
    • linux:
      An object of options to use when the build system is being executed on a Linux machine. Example: { "cmd": ["bash", "-c", "/usr/local/bin/my_command", "-d", "$file"] }
  • Example-1:

    • in c++ for implementing g++ -std=c++14 -o hello.out hello.cpp
     {
      "cmd":["bash", "-c", "g++ -std=c++14 -Wall '${file}' -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}'"],
      "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
      "working_dir": "${file_path}",
      "selector": "source.c, source.c++",
      "variants":
      [
     	 {
     		 "name": "Run",
     		 "cmd":["bash", "-c", "g++ -std=c++14 '${file}' -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}'"]
     	 }
      ]
     }
    
  • Example-2:

    • For C++: Create a new build system. File - "gcc-cpp.sublime-build"
     {
     	"shell_cmd": "g++ -std=c++17 ${file_path}/${file_name} -o ${file_path}/${file_base_name} && ${file_path}/${file_base_name}.exe"
     }
    
    • For C: Create a new build system. File - "gcc-c.sublime-build"
     {
     	"shell_cmd": "gcc -std=c11 ${file_path}/${file_name} -o ${file_path}/${file_base_name} && ${file_path}/${file_base_name}.exe"
     }
    
  • save the file (into the directory shown). Remember to give just the name, no extension (it will automatically take).

  • Create a build system for Javascript: 1. Create a file "Javscript.sublime-build" inside "Packages/Users" folder. 2. Choose Build system as this & build any file.

{
	"cmd": ["node", "$file"],
	"selector": "source.js"
}

  • Now, choose the build system.
  • References: For more, click here

Open with

Open your files (any type) using your .exe file.

NOTE: Firstly install SideBarEnhancements package.

Follow these steps:

  • Open the file in Sublime Text 3.
  • "Right click" on file
  • Click "Open with" option
  • A file - "Side Bar.sublime-menu" opens.
  • Now, set the commands for any file - Word, Excel, Image, etc.

Example 1: for Word 2013

//application 3
{
	"caption": "MS Word 2013",
	"id": "side-bar-files-open-with-word",

	"command": "side_bar_files_open_with",
	"args": {
						"paths": [],
						"application": "C:\\Program Files (x86)\\Microsoft Office\\Office15\\winword.exe",
						"extensions":"docx", //any file with extension (starting with doc i.e. doc, docx, docm,..)
						"args":[]
			},
	"open_automatically" : true// will close the view/tab and launch the application
},

Example 2: for Excel 2013

//application 4
{
	"caption": "MS Excel 2013",
	"id": "side-bar-files-open-with-excel",

	"command": "side_bar_files_open_with",
	"args": {
						"paths": [],
						"application": "C:\\Program Files (x86)\\Microsoft Office\\Office15\\excel.exe",
						"extensions":"xlsx", //any file with extension (starting with xls i.e. xls, xlsx, xlsm, xlsb,.)
						"args":[]
			},
	"open_automatically" : true// will close the view/tab and launch the application
},

NOTE: It's use is in Git Merge, while opening any binary file. Attach it with this settings in your editor - Sublime Text 3.

Troubleshooting

  • Disable ESC aping to COMMAND MODE
    • Just add this to your "Preferences >> Settings" & then choose right screen i.e. "Settings-User"
     "ignored_packages": ["Vintage"]

NOTE

  • Know spaces and tabs within code:
    When the code is selected-
    • all the tabs are marked with single dash line
    • all the spaces are marked with dotted lines