infiniteloop
infiniteloop

Reputation: 885

custom keybinding on find and Reg replace in sublime text?

Am thinking whether it's achievable to make shortcut key-bindings on user sublime key-map, so that one-key-triggered "find reg expression and replace-all" if can assign custom keybinding will save a lot of work.

For example can be applied to make below answer into shortcut: Sublime Text 2: How to delete blank/empty lines

Thanks to Joyas's answer, Below is the usage that could achieve the above task.

1.install RegReplace plugin for sublime 2/3

2.configure user reg replace function

      {
            "replacements": {
                "remove_blank_lines": {
                    "find" : "(^\n)",
                "replace": "",
                "greedy_replace": true
               }
            }
     }

3.configure key bindings

  {
    "keys": ["ctrl+shift+y"],
    "command": "reg_replace",
    "args": {"replacements": ["remove_blank_lines"]}
  }
  1. go to font-end press shortcut and it works so good!

Upvotes: 1

Views: 1368

Answers (1)

Joyas
Joyas

Reputation: 433

There is already a post here about custom shortcut in sublime text.

In order to change the default shortcut for find and replace, you just have to edit de the line

{ "keys": ["super+shift+f"], "command": "show_panel", "args": {"panel": "find_in_files"} }

in you preferences.

Furthermore, if you want to create a keybinding in order to "find and replace" a specific sequence of character, it seems that there is the plugin RegReplace to do so.

Upvotes: 3

Related Questions