<s> import sublime <EOL> from sublime_plugin import TextCommand <EOL> class GsInsertTextAtCursorCommand ( TextCommand ) : <EOL> """<STR_LIT>""" <EOL> def run ( self , edit , text ) : <EOL> text_len = len ( text ) <EOL> selected_ranges = [ ] <EOL> for region in self . view . sel ( ) : <EOL> selected_ranges . append ( ( region . begin ( ) , region . end ( ) ) ) <EOL> self . view . replace ( edit , region , text ) <EOL> self . view . sel ( ) . clear ( ) <EOL> self . view . sel ( ) . add_all ( [ sublime . Region ( begin + text_len , end + text_len ) <EOL> for begin , end in selected_ranges ] ) <EOL> class GsReplaceViewTextCommand ( TextCommand ) : <EOL> """<STR_LIT>""" <EOL> def run ( self , edit , text , nuke_cursors = False ) : <EOL> cursors_num = len ( self . view . sel ( ) ) <EOL> is_read_only = self . view . is_read_only ( ) <EOL> self . view . set_read_only ( False ) <EOL> self . view . replace ( edit , sublime . Region ( <NUM_LIT:0> , self . view . size ( ) ) , text ) <EOL> self . view . set_read_only ( is_read_only ) <EOL> if not cursors_num or nuke_cursors : <EOL> selections = self . view . sel ( ) <EOL> selections . clear ( ) <EOL> pt = sublime . Region ( <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> selections . add ( pt ) <EOL> class GsReplaceRegionCommand ( TextCommand ) : <EOL> """<STR_LIT>""" <EOL> def run ( self , edit , text , begin , end ) : <EOL> is_read_only = self . view . is_read_only ( ) <EOL> self . view . set_read_only ( False ) <EOL> self . view . replace ( edit , sublime . Region ( begin , end ) , text ) <EOL> self . view . set_read_only ( is_read_only ) <EOL> class GsHandleVintageousCommand ( TextCommand ) : <EOL> """<STR_LIT>""" <EOL> def run ( self , edit ) : <EOL> savvy_settings = sublime . load_settings ( "<STR_LIT>" ) <EOL> if savvy_settings . get ( "<STR_LIT>" , False ) is True : <EOL> self . view . settings ( ) . set ( "<STR_LIT>" , True ) <EOL> if savvy_settings . get ( "<STR_LIT>" , False ) is True : <EOL> self . view . run_command ( "<STR_LIT>" ) </s>
