#NEWLINE# def run( self , edit ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# text = sublime . get_clipboard ( ) #NEWLINE# if ( ( text is not None ) and ( len ( text ) > 0 ) ) : #NEWLINE# #INDENT# regions = [ ] #NEWLINE# sel = self . view . sel ( ) #NEWLINE# items = text . split ( '\n' ) #NEWLINE# if ( len ( items ) == 1 ) : #NEWLINE# #INDENT# items = [ text ] #NEWLINE# #UNINDENT# strip = True #NEWLINE# for ( idx , region ) in enumerate ( sel ) : #NEWLINE# #INDENT# if ( idx < len ( items ) ) : #NEWLINE# #INDENT# row = items [ idx ] . strip ( ) #NEWLINE# if region . empty ( ) : #NEWLINE# #INDENT# sublime . status_message ( 'empty' ) #NEWLINE# row = ( self . view . substr ( self . view . line ( ( self . view . line ( region ) . begin ( ) - 1 ) ) ) + '\n' ) #NEWLINE# i = 0 #NEWLINE# if len ( row . strip ( ) ) : #NEWLINE# #INDENT# i = self . view . insert ( edit , region . end ( ) , row ) #NEWLINE# #UNINDENT# regions . append ( sublime . Region ( ( region . end ( ) + i ) , ( region . end ( ) + i ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# sublime . status_message ( 'selection' ) #NEWLINE# self . view . replace ( edit , region , row ) #NEWLINE# i = len ( row ) #NEWLINE# regions . append ( sublime . Region ( ( region . begin ( ) + i ) , ( region . begin ( ) + i ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# sel . clear ( ) #NEWLINE# for region in regions : #NEWLINE# #INDENT# sel . add ( region ) #NEWLINE# pass #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# sublime . status_message ( 'No text found for Insert Text, canceled' ) #NEWLINE# #UNINDENT# #UNINDENT# except ValueError : #NEWLINE# #INDENT# sublime . status_message ( 'Error while executing Insert Text, canceled' ) #NEWLINE# pass