# non-rect multiple-selection text is returned contiguously with no delimiters of any type between! # example: 3-line rect block in virtual space in windows file returns '\r\n\r\n\r\n' # non-skinny rect block totally in virtual space returns only line-endings # non-skinny rect block returns line data separated by line-endings # skinny caret rect block always returns '' If leave_caret_here != None: tEmptySelection(leave_caret_here) New_sel_end = e_plus_ro + new_len - old_lenĮtSelection(new_sel_end, s_plus_ro)Įditor.addSelection(new_sel_end, s_plus_ro) # get out of column selection mode as it messes up trying to correctly set selections laterĮtEmptySelection(editor.getCurrentPos())Įditor.rereplace(find_what, replace_with, ignore_case_flag, s_plus_ro, e_plus_ro, max_num_of_replacements) Start_end_pos_tup_list.append(start_end_pos_tup) If append_it: start_end_pos_tup_list.append((s, e)) If editor.getSelectionNCaretVirtualSpace(n) > 0: append_it = False If editor.getSelectionNAnchor(n) 0: append_it = False # (could happen on empty lines inside the block) # prevent, e.g., a regex search for ^ from replacing "outside" a column-block's visual region (s, e) = (editor.getSelectionNStart(n), editor.getSelectionNEnd(n)) Leave_caret_here = editor.getCurrentPos() Start_end_pos_tup_list.append((0, editor.getTextLength())) # if start_end_pos_tup is None, replace will be done in all active selections Return ssageBox(msg, title, flags)ĭef custom_rereplace(self, find_what, replace_with, ignore_case_flag=0, max_num_of_replacements=0, start_end_pos_tup=None): If len(title) = 0: title = self.script_name Post-replace-summary : pops up a box after replacements are Made and a way to leave the matches selected Will be a way to cancel so that the replacements aren't Made, telling how many there will be at that point there Pre-replace-preview : pops up a box BEFORE replacements are Self.remembered_post_repl_summary_setting = False Self.remembered_pre_repl_preview_setting = False Self.remembered_whole_word_setting = False Self.remembered_case_sens_setting = False Self.script_name = inspect.getframeinfo(inspect.currentframe()).filename.split('\\') That’s it here’s the listing for the script, ReplaceAllInSelections.py: # -*- coding: utf-8 -*. If you have selected the “post-replacement-summary” option, after replacements have been made, you will see a box like this appear: If you have chosen the “pre-replace-count-preview” option, you will get a prompt like this before the document text is changed:Ĭhoosing Yes from there will do the replacing without further prompt.Ĭhoosing No will result in an additional prompt: To use the options, you put an x inside the brackets in front of an option you want to select example to select case sensitivity:Īfter everything has been specified, press OK and the replacement(s) will be made in the active selection(s). Specifying other options, like case sensitivity, regular expression mode, etc.: Specifying what you want to replace the found matches with: You will be prompted through a series of dialog boxes to provide your parameters for the replacement operation: Make your selection(s) and then run the script.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |