Friday, September 06, 2019

Keyboard shortcut for "replace in selection" in Brackets

I recently moved from Notepad++ to Brackets for coding some of the dynamic elements in Moodle course content. With its modern UI, live preview feature, and very useful Emmet extension, Brackets has given a boost to my workflow. Strangely, a simple feature is missing in Brackets: you can't replace characters within a selection of text. There is however an extension for this called, quite simply, "Replace in selection". Finding and installing it is straightforward using the Brackets extension manager, and the brief help text says that the keyboard shortcut is Control + R.

But that shortcut didn't work for me. What use is a find/replace function without a keyboard shortcut?

Looking at the user key bindings in Brackets (Debug -> open user key map), I realised I had to figure out the command ID for this feature. The main.js file of this extension indicated that it might be "replaceInSelection.Replace". And that it was indeed - I added the following to the key map file and the keyboard shortcut worked!

"overrides": {
         "Ctrl-R":  "replaceInSelection.Replace"
    }

No comments:

Post a Comment