Do you want remove all empty whitespace lines in a file removed? What exactly are you looking for. Without seeing an example of what you mean, I am not sure I can help. RegReplace does not currently search and replace within a selection, but it could in the future. I can help you construct a rule for RegReplace, if I know exactly what it is you want.

RegReplace either searches a whole file, or finds the first instance after your cursor (you tell it what you want it to do). I can help if you can give me a good example. If you absolutely need it to work under a selection, I can look into adding it in the future.

Add this to your replacement definitions in RegReplace. You can see I am avoiding PHP source code and javascript; you can add additional if you like. You can also tweak this further if it doesn't do exactly what you want.

// If on_save is true, RegReplace will search through the file patterns listed below right before a file is saved, // if the file name matches a file pattern, the sequence will be applied before the file is saved. // RegReplace will apply all sequences that apply to a given file in the order they appear below. "on_save": false, "on_save_sequences": [ // An example on_save event that removes dangling commas from json files // - file_regex: an array of regex strings that must match the file for the sequence to be applied // - case: regex case sensitivity (true|false) false is default (this setting is optional) // - file_pattern: an array of file patterns that must match for the sequence to be applied // - sequence: an array of replacement definitions to be applied on saving the file { "file_regex": [".*\\.sublime-(settings|commands|menu|keymap|mousemap|theme|build|project|completions|commands)"], "file_pattern": ["*.json"], "sequence": ["remove_json_dangling_commas"] }, // An example on_save_sequence that targets all files and trims trailing spaces // - file_pattern: an array of file patterns that must match for the sequence to be applied // - sequence: an array of replacement definitions to be applied on saving the file {"file_pattern": ["*"], "sequence": ["remove_trailing_spaces"]} ],