Skip to content

Instantly share code, notes, and snippets.

@nolanlawson
nolanlawson / .gitignore
Last active October 14, 2021 06:40
Shadow DOM style benchmark
node_modules
*.tachometer.json
*.results.json
@OdatNurd
OdatNurd / hover_bookmark_toggle.py
Created March 10, 2021 23:34
Sublime Text 3 bookmark hover toggle
import sublime
import sublime_plugin
class BookmarkEventListener(sublime_plugin.EventListener):
def toggle_bookmarks(self, view, point):
# Get existing bookmarks and create a region for the new one
bookmarks = view.get_regions("bookmarks")
new = sublime.Region(point)
@KyleJamesWalker
KyleJamesWalker / README.md
Created February 17, 2021 20:14
Filter Long Descriptions from LastPass Export for BitWarden Import

Overview

When trying to import my LastPass passwords, I had many that were over 1000 characters for the notes, so this script simply filters out the values that are likely too long.

Once this has been run you will have 2 files, one that can be imported, and the other can be edited, or broken up to allow the remaining import.

@OdatNurd
OdatNurd / snippet_folder.py
Created February 15, 2021 09:30
Sublime Text 4 plugin to expand snippets and automatically fold parts of them up
import sublime
import sublime_plugin
class ExpandAndFoldSnippetCommand(sublime_plugin.TextCommand):
def run(self, edit, name, folds):
self.view.run_command("insert_snippet", {"name": name})
for _ in range(folds):
self.view.run_command("fold")
@OdatNurd
OdatNurd / Default.sublime-commands
Created January 20, 2021 05:16
Easily open the Sublime Plugin API files
[
{ "caption": "Developer: Open API Files", "command": "open_api_files" },
]
@OdatNurd
OdatNurd / edit_examples.py
Created December 21, 2020 07:28
Sample plugin showing how to edit, replace and erase text in a Sublime Text plugoin
import sublime
import sublime_plugin
class ExampleCommand(sublime_plugin.TextCommand):
def run(self, edit):
self.view.insert(edit, 0, "Hello, World!")
class SecondExampleCommand(sublime_plugin.TextCommand):
@OdatNurd
OdatNurd / view_tests.py
Created December 14, 2020 07:59
Plugin example: How to work with Points and Regions in Sublime Text
import sublime
import sublime_plugin
class RegionExampleCommand(sublime_plugin.TextCommand):
def run(self, edit, example):
if example == "1": region = sublime.Region(0, 10)
elif example == "2": region = sublime.Region(10, 20)
elif example == "3": region = sublime.Region(5)
elif example == "4": region = self.view.word(5)
@OdatNurd
OdatNurd / key_context_example.py
Created November 19, 2020 19:00
Defining a custom settings key context for Sublime Text that can compare any setting and not just booleans
import sublime
import sublime_plugin
class CustomContextEventListener(sublime_plugin.EventListener):
"""
This event is raised when Sublime sees a key binding context key it does not
recognize.
"""
def on_query_context(self, view, key, operator, operand, match_all):
@OdatNurd
OdatNurd / .python-version
Last active July 8, 2024 03:37
Browse all Sublime Text commands provided by plugins
3.8
import sublime
import sublime_plugin
class CompletionListener(sublime_plugin.ViewEventListener):
def on_query_completions(self, prefix, locations):
completion_list = sublime.CompletionList()
sublime.set_timeout_async(lambda: self._on_query_completions_async(completion_list, locations[0]))
return completion_list