Sublime Markdown Editor Shot

I was disappointed to find that there weren’t any good packages available for Sublime Text 2 that added decent Markdown editing features. I figured it was time to learn my way around. I still haven’t dug into Python, so my script-fu in there is weak right now. I got a few things working, though, and this will evolve as I learn new things. I’ll probably look back at this first version with embarrassment, but I’ll just overwrite it with better stuff as it progresses.

From the README on the Github repo:

This package will make MarkdownEditor your default theme for Markdown/MultiMarkdown files. Adjust it to your liking or remove the line from the .sublime-settings files

  • Asterisks and underscores are autopaired and will wrap selected text
  • If you start an empty pair and hit backspace, both elements are deleted
  • If you start an empty pair and hit space, the right element is deleted
  • backticks are paired
  • Left bracket pairing is modified to eliminate the selection and leave the cursor at a point where you can insert a [] or () pair for a link
  • V will paste the contents of the clipboard as an inline link on selected text
  • R will paste the contents of the clipboard as a reference link
  • K inserts a standard inline link, K inserts an inline image
  • B and I are bound to bold and italics (Markdown). If you don’t like losing your default shortcut for “Build”, modify the sublime-keymap file. This only overrides while editing Markdown files.

There’s a long way to go and I have a lot of Python to learn.

The theme pays some homage to Byword, but I make no pretense that it’s anywhere as pretty.

Installation

Just download or clone the MarkdownEditing repo into a MarkdownEditing folder within your ~/Library/Application Support/Sublime Text 2/Packages folder. You may have to restart Sublime to get it working, but once it’s installed (if all goes well), you should be able to open a Markdown file and see my custom theme. If you do, then the features listed above should also be available.

Right now, this is designed to be tweaked. I can’t guess what you’re preferred editing environment is like, so I went with mine. I’d love to see any permutations you come up with.

Oh, and by the way, if you’re doing any theming for Sublime Text, here’s a handy little plugin I whipped up to copy the scope of the character after the cursor to the clipboard for easily adding keys to a .tmtheme XML file:

copy_scope.pyraw
"
import sublime, sublime_plugin

class CopyScopeCommand(sublime_plugin.TextCommand):
	def run(self, edit):
		sublime.set_clipboard(self.view.scope_name(self.view.sel()[0].begin()))
		sublime.status_message("Copied scope")

	def is_enabled(self):
		return self.view.sel()

# To call the command, add the following to Preferences->Key Bindings - User:
# { "keys": ["shift+super+alt+p"], "command": "copy_scope" }

Also check out Philip Belesky’s Byworded themes for TextMate and Sublime Text 2.