Skip to content

Instantly share code, notes, and snippets.

@kellishaver
Created June 26, 2012 15:32
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save kellishaver/2996448 to your computer and use it in GitHub Desktop.
Save kellishaver/2996448 to your computer and use it in GitHub Desktop.
Sublime Text 2 Block Cursor - outside of Vintage Mode
import sublime
import sublime_plugin
class SublimeBlockCursor(sublime_plugin.EventListener):
def view_is_widget(view):
settings = view.settings()
return bool(settings.get('is_widget'))
def show_block_cursor(self, view):
validRegions = []
for s in view.sel():
if s.a != s.b:
continue
validRegions.append(sublime.Region(s.a, s.a + 1))
if validRegions.__len__:
view.add_regions('SublimeBlockCursorListener', validRegions, 'block_cursor')
else:
view.erase_regions('SublimeBlockCursorListener')
def on_selection_modified(self, view):
if view.settings().get('is_widget'):
view.erase_regions('SublimeBlockCursorListener')
return
self.show_block_cursor(view)
def on_deactivated(self, view):
view.erase_regions('SublimeBlockCursorListener')
def on_activated(self, view):
self.show_block_cursor(view)
@robwala
Copy link

robwala commented Aug 27, 2012

Thanks for making this available - much appreciated!

@Iristyle
Copy link

Sweet!

@Iristyle
Copy link

Any chance you would want to publish to a git repo and make it available through package control?
http://wbond.net/sublime_packages/package_control

If not, I can do it....

@tvby
Copy link

tvby commented Oct 19, 2012

Is it possible to get this to work with SublimeMarkAndMove?

@kellishaver
Copy link
Author

Wow, I didn't even notice all of the comments on this until now. I've not used SublimeMarkAndMove (though I want to now that I know of its existence) so I'd have to look into it. I know this works with the regular multi-select that's baked in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment