Sublime Text 2: Difference between revisions

From wikinotes
 
No edit summary
Line 1: Line 1:
Sublime Text 2 is a text editor that comes with it's own built-in package manager.
Sublime Text 2 is a text editor, with a builtin package manager.
For the most part, SublimeText automatically detects the type of file you are writing to, and
activates appropriate syntax highlighting


= Default Hotkeys =
<blockquote>
{| class="wikitable"
{| class="wikitable"
| Hotkeys || ||
| Hotkeys || ||
|-
|-
| <pre>CTRL + R</pre> || || List Functions
| <pre>CTRL + R</pre> || || List Functions
Line 16: Line 16:
| <pre>CTRL + NUM</pre> || || Select Column
| <pre>CTRL + NUM</pre> || || Select Column
|}
|}
</blockquote><!-- Default Hotkeys -->


= Config Files =
= Config Files =
Line 24: Line 25:
| <pre>~/.config/sublime-text-2/Packages/Default (Linux).sublime-keymap</pre> || || [[SublimeText2 UserKeyPrefs]] || key config
| <pre>~/.config/sublime-text-2/Packages/Default (Linux).sublime-keymap</pre> || || [[SublimeText2 UserKeyPrefs]] || key config
|}
|}
<pre>
## Packages:
Vintage Mode
VintageEx
Chain Of Command
sublimetext-syntaxfold
MayaSublime
Markdown Preview
LiveReload
</pre>
</blockquote><!-- Config Files -->
</blockquote><!-- Config Files -->
<br>
<br>
= Custom Plugins =
<blockquote>
== getting started ==
<blockquote>
''' Plugin Packaging Standards '''
{| class="wikitable"
| /home/will/.config/sublime-text-2/Packages/MYPACKAGE/MYPACKAGE.py || || Sublime Packaging Standards
|}
SublimeText uses python for all of it's plugins. In order for them to be discovered, you must place
both a python script, and a folder of the same name in the packages folder.
''' Function Names and CamelCase '''<br>
In order for sublimetext commands to be run from it's embedded python interpreter, they
must be classes with each letter Capitalized followed by 'Command'. These classes receive
one of sublimeText's premade objects( that define what type of information we are processing ).
Then within that class, you need a method called 'run'.<br>
Camelcase is a naming convention where the first letter of every word in a function name
is capitalized. When running commands from sublime's interpreter:
- the suffix of 'Command' is stripped
- the entire string is made lowercase
- each word is separated by a '_'
<syntaxhighlight lang="python">
#### Example:
import sublime, sublime_plugin
            +-----------------------------------------------------------+
            |                                                          |
class MyExampleCommand(sublime_plugin.TextCommand):                      |
    def run(self, edit):                                                |  (Same Command)
        self.view.insert(edit, 0, "Hello, World!")                      |
                                                                        |
                                                                        |
## You can then open sublimeText's python interpreter with (Ctrl + `)    |
## or 'View > View Console'                                              |
## and run the commmand.                                                |
view.run_command("my_example")                                          |
                      |                                                |
                      +-------------------------------------------------+
</syntaxhighlight>
</blockquote><!-- getting started -->
</blockquote><!-- Custom Plugins-->
<br>
<br>


= Packages/Extensions =
= Packages/Extensions =
<blockquote>
<blockquote>
 
== Install Package Manager ==
=== Install Package Manager ===
-----
<blockquote>
<blockquote>
<pre>
<pre>
Line 102: Line 37:
import urllib2,os; pf='Package Control.sublime-package'; ipp=sublime.installed_packages_path(); os.makedirs(ipp) if not os.path.exists(ipp) else None; urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler())); open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read()); print('Please restart Sublime Text to finish installation')
import urllib2,os; pf='Package Control.sublime-package'; ipp=sublime.installed_packages_path(); os.makedirs(ipp) if not os.path.exists(ipp) else None; urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler())); open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read()); print('Please restart Sublime Text to finish installation')
</pre>
</pre>
</blockquote><!-- Install Package Manager -->
</blockquote><!-- Install Package Manager -->


=== Installing Packages ===
== Installing Packages ==
-----
<blockquote>
<blockquote>
Here is an example of how to install a package
Here is an example of how to install a package
<pre>
<pre>
Line 117: Line 48:
** Enter
** Enter
</pre>
</pre>
 
</blockquote><!-- Installing Packages -->
 
=== Vintage Mode, Vintage Ex ===
-----
<blockquote>
One of the best features of sublime text is the built-in ability to be run with vim-style hotkeys.
combined with the code preview/drag bar, and the nice colours sublime text in vintage mode is easily
THE choice of text editor, missing only the ability to be run within a terminal.
 
''' vintage-mode '''
Preferences > User Settings:
<pre>
"vintage_start_in_command_mode": true,
"ignored_packages":
  [
    //"Vintage"
  ]
</pre>
 
 
''' Vintage Ex '''
<pre>
Ctrl + Shift + P
Install Package
vintage ex
</pre>
 
 
 
</blockquote>
 
=== Markdown ===
-----
<blockquote>
Markdown is a kind of short-form HTML. I have been considering implementing Markdown for free-form notes for my own
personal research. It must be converted from Markdown to HTML for your browser to read it correctly. Markdown has several
file extensions, but I prefer *.md
 
SublimeText2 Packages for Markdown:
==== LiveReload ====
<blockquote>Reloads your website in your browser when doc is saved
You must also install the Browser extensions: https://github.com/dz0ny/LiveReload-sublimetext2
</blockquote>
 
==== MarkdownPreview ====
<blockquote>
Converts your file from a .md to html, and loads it in the browser of your choice.
Note that Live Reload + Markdown Preview work together, but it only refreshes once properly
in windows. I will need to hit F5 for updates in the browser window
</blockquote>
 
==== Markdown Syntax Highlighting ====
<blockquote>
SublimeText2 does not come with full syntax highlighting for Markdown. This will fix it. Navigate to:
{| class="wikitable"
!colspan=2| Code Changes
|-
| Markdown Addition to Colorscheme || [[sublimetext2 markdown-syntax-highlight]]
|-
!colspan=2| Locations
|-
| Windows || <code>C:\Users\Will\AppData\Roaming\Sublime Text 2\Packages\Color Scheme - Default</code>
|-
| Archlinux ||
|-
|}
 
Open the file, and paste the above code inside it just before <nowiki><pre></array></pre></nowiki>
 
 
 
</blockquote><!-- syntaxhighlight -->
</blockquote><!-- Markdown -->
 
=== Mel, PyMel ===
-----
<blockquote>
''' Git '''
You'll need to install git, or git portable. Git portable works, but I've had
some minimal problems with the portable version of git when integrating it
into sublime text. Install where possible, or extract if no admin privileges.
 
http://code.google.com/p/msysgit/downloads/list
 
==== MayaSublime ====
Browse to sublime Text's package directory. If you aren't sure of it's location,
* Sublime Text > Preferences > Browse Packages
* Shift + rclick > Open CMD at current Location
 
<syntaxhighlight lang="bash">
## Local Git Install:
cd C:\Users\will\AppData\Roaming\Sublime Text 2\Packages
cd /home/will/.config/sublime-text-2/Packages
git clone git://github.com/justinfx/MayaSublime.git
 
## Portable Git Install:
cd C:\Users\will\AppData\Roaming\Sublime Text 2\Packages
"C:\users\will\Documents\~ Portable\Git\bin\git.exe" clone git://github.com/justinfx/MayaSublime.git
 
## If you are running this on a unix derivative, you may need to
## make MayaSublime/MayaSublime.py executable with 'chmod +x MayaSublime.py'
#
## In order to execute commands from Sublime Text, you must
## execute the following in Maya:
commandPort -n ":7001";
</syntaxhighlight>
 
</blockquote><!--Mel, Pymel-->
<br>
<br>
 
 
=== sublime-customfolding ===
-----
<blockquote>
<syntaxhighlight lang="bash">
cd /home/will/.config/sublime-text-2/Packages
 
git clone https://github.com/diametric/sublime-customfolding.git
cp -R /home/will/.config/sublime-text-2/Packages/sublime-customfolding/sublime_customfolding /home/will/.config/sublime-text-2/Packages/
 
### Settings - User
{
"customfolding_tags": [ ["{{{","}}}"] ],
"customfolding_onload_all": true
}
 
### Package Settings > Settings - User
{
"in_process_packages": [],
"installed_packages": ["sublime_customfolding"]
}
 
</syntaxhighlight>
 
I do have this working now, for everything except the final fold. It's a little buggy,
but it will get people used to it... I guess...
 
{|
| https://github.com/diametric/sublime-customfolding.git
|}
 
</blockquote><!-- sublimetext-syntaxfold -->
<br>
<br>
 
=== alignTab ===
<blockquote>
Tabular for sublimeText:
 
https://github.com/randy3k/AlignTab
</blockquote>
 
=== FileDiff ===
-----
<blockquote>
This allows you to create a diff file (patch file) with the changes between two files.
This is not like using meld, it just creates a file you can use to patch another file.
 
''' Usage '''
* <code>Ctrl + Shift + P</code> > FileDiffs:Menu > Diff file with open tab
* This will create a new tab with the changes needed to make the current tab the same as the second open tab
</blockquote><!--FileDiff-->
 
 
</blockquote><!-- Packages/Extensions-->
</blockquote><!-- Packages/Extensions-->

Revision as of 01:09, 2 July 2022

Sublime Text 2 is a text editor, with a builtin package manager.

Default Hotkeys

Hotkeys
CTRL + R
List Functions
CTRL + SHIFT + P
Enter Command (install package, markdown preview, etc)
ALT + SHIFT + NUM
Switch Column Views
CTRL + SHIFT + NUM
Move Window to Specific Column
CTRL + NUM
Select Column

Config Files

~/.config/sublime-text-2/Packages/User/Preferences.sublime-settings
SublimeText2 Userprefs main config
~/.config/sublime-text-2/Packages/Default (Linux).sublime-keymap
SublimeText2 UserKeyPrefs key config

Packages/Extensions

Install Package Manager

## Push CTRL+~ to get the terminal
## Copy + Paste the following code

import urllib2,os; pf='Package Control.sublime-package'; ipp=sublime.installed_packages_path(); os.makedirs(ipp) if not os.path.exists(ipp) else None; urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler())); open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read()); print('Please restart Sublime Text to finish installation')

Installing Packages

Here is an example of how to install a package

CTRL + SHIFT + P					# Gives you a UI line
Package Install					# Package Installer
Live Reload							# Search for package to install
** Enter