Sublime Text 2: Difference between revisions

From wikinotes
 
 
(2 intermediate revisions by the same user not shown)
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


{| class="wikitable"
= Default Hotkeys =
| Hotkeys || || 
<blockquote>
|-
<syntaxhighlight lang="yaml">
| <pre>CTRL + R</pre> || || List Functions
ctrl + r:            # list functions
|-
ctrl + shift + p:    # ener command (install package, markdown preview, etc)
| <pre>CTRL + SHIFT + P</pre> || || Enter Command (install package, markdown preview, etc)
alt + shift + num:  # switch column views
|-
ctrl + shift + num:  # move window to specific column
| <pre>ALT + SHIFT + NUM</pre> || || Switch Column Views
ctrl + num:          # select column
|-
</syntaxhighlight>
| <pre>CTRL + SHIFT + NUM</pre> || || Move Window to Specific Column
</blockquote><!-- Default Hotkeys -->
|-
| <pre>CTRL + NUM</pre> || || Select Column
|}


= Config Files =
= Config Files =
<blockquote>
<blockquote>
{| class="wikitable"
{| class="wikitable"
| <pre>~/.config/sublime-text-2/Packages/User/Preferences.sublime-settings</pre> || || [[SublimeText2 Userprefs]] || main config
| <code>~/.config/sublime-text-2/Packages/User/Preferences.sublime-settings</code> || main config
|-
|-
| <pre>~/.config/sublime-text-2/Packages/Default (Linux).sublime-keymap</pre> || || [[SublimeText2 UserKeyPrefs]] || key config
| <code>~/.config/sublime-text-2/Packages/Default (Linux).sublime-keymap</code> || 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 31:
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 42:
** 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-->

Latest revision as of 01:12, 2 July 2022

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

Default Hotkeys

ctrl + r:            # list functions
ctrl + shift + p:    # ener 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 main config
~/.config/sublime-text-2/Packages/Default (Linux).sublime-keymap 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