Sublime Forum

Replacing all selected text by spaces

#1

is that possible with sublime by default?
any extension to do that?

The case is that, I have a file with plenty text to clean up, so a way I am doing is selecting pieces, and substituting for the same amount of spaces, so file estructure keeps the same

just looking a way to automate it

0 Likes

#2
  • Find menu -> Replace
  • enable regex mode if not already enabled
  • enable in selection mode
  • find .
  • replace with space
  • replace all
0 Likes

#3

It’s easy to create a plugin for that. Select Tools > Developer > New Plugin… paste and save:

import sublime_plugin


class ReplaceBySpaceCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        view = self.view
        for sel in view.sel():
            new_content = len(view.substr(sel)) * " "
            view.replace(edit, sel, new_content)

Then create a keybinding:

    {
        "keys": ["ctrl+alt+shift+a"],
        "command": "replace_by_space",
    },
2 Likes

#4

Thanks a lot to both
@kingkeith I tried before an dI didn’t make to work, but no yes, so perfect
@r-stein Great !!, i will try it , perfecto also

0 Likes