<s> import re <EOL> import sublime <EOL> import sublime_plugin <EOL> class IndentQuote ( sublime_plugin . TextCommand ) : <EOL> def description ( self ) : <EOL> return '<STR_LIT>' <EOL> def run ( self , edit ) : <EOL> view = self . view <EOL> selections = view . sel ( ) <EOL> new_selections = [ ] <EOL> for selection in selections : <EOL> lines_in_selection = self . view . lines ( selection ) <EOL> all_lines = [ ] <EOL> expanded_selection_start = lines_in_selection [ <NUM_LIT:0> ] . begin ( ) <EOL> for line in lines_in_selection : <EOL> complete_line = view . line ( line ) <EOL> expanded_selection_end = complete_line . end ( ) <EOL> text = view . substr ( complete_line ) <EOL> all_lines . append ( "<STR_LIT>" + text ) <EOL> expanded_selection = sublime . Region ( expanded_selection_start , expanded_selection_end ) <EOL> replacement_text = "<STR_LIT:\n>" . join ( all_lines ) <EOL> view . replace ( edit , expanded_selection , replacement_text ) <EOL> new_selections . append ( sublime . Region ( expanded_selection_start , expanded_selection_start + len ( replacement_text ) ) ) <EOL> selections . clear ( ) <EOL> for selection in new_selections : <EOL> selections . add ( selection ) <EOL> def is_enabled ( self ) : <EOL> return bool ( self . view . score_selector ( self . view . sel ( ) [ <NUM_LIT:0> ] . a , "<STR_LIT>" ) ) <EOL> class DeindentQuote ( sublime_plugin . TextCommand ) : <EOL> def description ( self ) : <EOL> return '<STR_LIT>' <EOL> def run ( self , edit ) : <EOL> view = self . view <EOL> selections = view . sel ( ) <EOL> new_selections = [ ] <EOL> for selection in selections : <EOL> lines_in_selection = self . view . lines ( selection ) <EOL> all_lines = [ ] <EOL> expanded_selection_start = lines_in_selection [ <NUM_LIT:0> ] . begin ( ) <EOL> for line in lines_in_selection : <EOL> complete_line = view . line ( line ) <EOL> expanded_selection_end = complete_line . end ( ) <EOL> text = view . substr ( complete_line ) <EOL> all_lines . append ( re . sub ( r'<STR_LIT>' , '<STR_LIT>' , text ) ) <EOL> expanded_selection = sublime . Region ( expanded_selection_start , expanded_selection_end ) <EOL> replacement_text = "<STR_LIT:\n>" . join ( all_lines ) <EOL> view . replace ( edit , expanded_selection , replacement_text ) <EOL> new_selections . append ( sublime . Region ( expanded_selection_start , expanded_selection_start + len ( replacement_text ) ) ) <EOL> selections . clear ( ) <EOL> for selection in new_selections : <EOL> selections . add ( selection ) <EOL> def is_enabled ( self ) : <EOL> return bool ( self . view . score_selector ( self . view . sel ( ) [ <NUM_LIT:0> ] . a , "<STR_LIT>" ) ) </s>
