public

  • Download Gist
add_number_to_multiselects.py
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
import sublime
import sublime_plugin
import string
 
class MultiSelectNumbersCommand( sublime_plugin.TextCommand ):
def run(self, edit):
view = self.view;
window = view.window()
 
def countThoseSelections(pattern):
view.run_command( 'multi_select_helper', { 'pattern' : pattern } )
window.show_input_panel('Count Start:Step', '1:1', countThoseSelections, False, False)
 
 
class MultiSelectHelperCommand( sublime_plugin.TextCommand ):
def run( self, edit, pattern ):
view = self.view;
pattern = pattern.split( ':' )
region_index = int( pattern[0] )
 
for region in view.sel():
replaceRegion = sublime.Region( region.begin() - 1, region.begin() )
prevChar = view.substr( replaceRegion )
if( prevChar == '#' ):
view.replace( edit, replaceRegion, str( region_index ) )
region_index = region_index + int( pattern[1] )

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.