Skip to content

Instantly share code, notes, and snippets.

View jbjornson's full-sized avatar

Josh Bjornson jbjornson

  • Zürich, Switzerland
View GitHub Profile
@jbjornson
jbjornson / oracle_commands.py
Created January 30, 2014 08:20
SublimeText 3 version for OracleSQL file oracle_commands.py (https://github.com/bizoo/OracleSQL)
import sublime
import sublime_plugin
import OracleSQL.oracle_lib
class OracleGotoBodyCommand(sublime_plugin.TextCommand):
def run(self, edit):
def _on_change(result):
try:
ln = int(result) - 1
@jbjornson
jbjornson / oracle_exec.py
Created January 30, 2014 08:07
SublimeText 3 version for OracleSQL file oracle_exec.py (https://github.com/bizoo/OracleSQL)
import sublime
import re
import os.path
import os
from . import oracle_lib
from Default import exec as execmod
RE_ENTITIES = re.compile("^\\((.+?)/(0):[0-9]+\\) ([0-9]+):[0-9]+ (.+)$", re.M)
class OracleExecCommand(execmod.ExecCommand):
@jbjornson
jbjornson / backup_file.py
Created August 27, 2012 09:30
SublimeText plugin to make, view and diff backups for a file.
'''
@author Josh Bjornson
This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License.
To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/
or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.
'''
import sublime, sublime_plugin
import glob, os, shutil, codecs, time, difflib, datetime
@jbjornson
jbjornson / SwitchToFile.py
Last active October 29, 2015 19:45
Show a input panel to switch to a currently open file
import sublime_plugin
import os
# -------------------------------------------
# You will need to create a key mapping for this, something like:
# { "keys": ["alt+e"], "command": "switch_to_file" }
# -------------------------------------------
class SwitchToFileCommand(sublime_plugin.WindowCommand):
def run(self):
self.display_list = []
self.views = []
@jbjornson
jbjornson / open_filename_under_cursor.py
Created September 1, 2011 13:09
Open the filename from either the current selection or the clipboard. If neither of these are files, then create a new filename based on the selection.
import sublime, sublime_plugin
import os.path, string
VALID_FILENAME_CHARS = "-_.() %s%s%s" % (string.ascii_letters, string.digits, "/:\\")
# { "keys": ["alt+o"], "command": "open_filename_under_cursor" }
# https://gist.github.com/1186126
class OpenFilenameUnderCursor(sublime_plugin.TextCommand):
def run(self, edit):
for region in self.view.sel():
@jbjornson
jbjornson / slurp_line_using_clipboard.py
Created August 29, 2011 15:27
Search for the text in the clipboard and cut the containing line to the clipboard
import sublime, sublime_plugin, re
# Search for the text in the clipboard and cut the containing line to the clipboard
# { "keys": ["alt+x"], "command": "slurp_line_using_clipboard" }
# https://gist.github.com/1178622
class SlurpLineUsingClipboardCommand(sublime_plugin.TextCommand):
def run(self, edit, block=True):
search_string = re.escape(sublime.get_clipboard())
region = self.view.find(search_string, 0, sublime.IGNORECASE)
@jbjornson
jbjornson / open_file_in_folder.py
Last active September 26, 2015 23:48
Display a quick panel with the other files in the directory of the current file
'''
@author Josh Bjornson
This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License.
To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/
or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.
'''
import sublime, sublime_plugin
import glob, os
@jbjornson
jbjornson / convert_to_fixed_column.py
Created August 29, 2011 15:19
Convert a CSV file to fixed width
import sublime_plugin
# { "keys": ["alt+m"], "command": "convert_to_fixed_column", "args": {"split_char": ";"}}
# https://gist.github.com/1178594
class ConvertToFixedColumnCommand(sublime_plugin.TextCommand):
def run(self, edit, split_char=';'):
for region in self.view.sel():
self.view.replace(edit, region, self.align_content(self.view.substr(region), split_char))
def align_content(self, content, split_char):
@jbjornson
jbjornson / open_recently_closed_file.py
Last active July 27, 2017 20:35
Plugin that keeps track of which files have been recently closed, as well as files that have been recently accessed. The plugin can be used to simply open the last file you closed or can be used to display a quick panel with a list of recently accessed f
'''
@author Josh Bjornson
This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License.
To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/
or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.
'''
# Plugin to provide access to the history of accessed files:
# https://gist.github.com/1133602
#