Support » Plugin: Code Snippets » Feature Request – Codemirror search and replace

  • Resolved mjdewitt

    (@mjdewitt)


    Hi,

    I Love code Snippets. I can’t imagine working on WP without it.

    It would be great to take advantage of some of the Codemirror addons like search and replace. There are probably others, but I haven’t had time to go through the list.

    I have looked through the settings and what I can find for DOCS, but can’t seem to find anything on enhancing Codemirror for Snippets?

    Would you kindly point me to where I can learn how to implement these features or consider this a feature request.

    Thanks for a great plugin.

    Mike

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Shea Bunge

    (@bungeshea)

    Hi Mike,

    My apologies for taking so long to get back to you about this.

    Currently, I am only including the matchbrackets addon in CodeMirror. It would be fairly easy to bundle additional addons with the plugin, so if you find any that you think would be generally useful for all users, let me know and I can include them.

    Otherwise, you can always download a copy of CodeMirror and load the addon JavaScript files on the edit page. Code Snippets generally uses the latest available version of the library, so you’ll want to make sure you keep it up to date.

    Hey Shea,

    I finally got around to checking it out and as much as I would like search and replace, I don’t think codemirror is going to deliver.

    I tried it out and modules loaded, no errors in the console, but just doesn’t seem to work. I decided to look for a working demo and can’t seeem to find one.

    Comments on git are less than encouraging.

    Mike

    Plugin Author Shea Bunge

    (@bungeshea)

    I’ll see what I can do to integrate a copy of the search replace addon into the plugin itself.

    Plugin Author Shea Bunge

    (@bungeshea)

    I’ve added the search replace addon into the plugin itself. The keymaps are listed on this page, and will be working in the next plugin release.

    Hopefully this will be useful for you.

    Hey Shea,

    Thanks for looking into this. Is this ready as of 2.12.1? Or, did you meant the next release?

    When I mentioned broken before, I was referring to the key-bindings as both Chrome and Firefox already have key bindings for alt-f, ctl-f.

    I do see that this demo, https://codemirror.net/demo/search.html, works for me (now), but Snippets does not. But maybe it isn’t ready yet?

    Mike

    PS I noticed that the theme editor has buttons and responds to codemirror key bindings. Is it a big deal to implement the same interface for Snippet editing?

    Plugin Author Shea Bunge

    (@bungeshea)

    Hi Mike,

    My apologies for taking so long to respond to this. The changes have been made in the development version of the plugin, so I meant in the next release after 2.12.1. It will have the proper key bindings as mentioned on that page.

    I’m not fully sure what WordPress is using to add buttons above theme editor, but I will take a look and see if I can integrate them with the snippet editor.

    Plugin Author Shea Bunge

    (@bungeshea)

    Hi again Mike,

    Taking another look at the theme editor, I can’t see any interface buttons. Am I looking in the right spot?

    Here’s a screenshot of what my theme editor looks like.

    Hi Shea,

    I can understand your confusion since you don’t have the buttons. I emailed you a screenshot of my editor. This is how it has always been for me.

    Mike

    mjdewitt

    (@mjdewitt)

    Shea,

    Apologies again on the confusion with the buttons.

    I just checked out the search and replace and they work great.

    Since this is new feature is hidden, it would be nice to have a note added to the UI (maybe under “Code?”) alerting people that (cntl-f) will search and (shift-cntl-f) will replace.

    Thank you for this awesome feature.

    Best,

    Mike

    Plugin Author Shea Bunge

    (@bungeshea)

    Hi Mike,

    Do you think that having an area under the ‘Help’ tab in the top-right-hand of the screen would be sufficient? I’m just trying to think of the best way to work this into the UI without cluttering things up too much.

    Thank you for your help in implementing this!

    mjdewitt

    (@mjdewitt)

    Happy New Year Shea,

    I am glad you agree that some notice of the ability to do search/replace within a Snippet is needed. For me, I tend to ignore stuff under the help tag as that is where all of the WP notices/nags appear.

    I would prefer to have the “link” to the keyboard shortcut list above the editing area. I think perhaps something as simple as “<Shortcuts>” with a low opacity that on hover, fades to full opacity as it displays the list of keyboard commands as “title” text. To be fancy, you could open a modal window.

    The other location that I think would work is above the “Description.” This can either be on the same line as “Run snippet everywhere” or it’s own line.

    I understand your concern over clutter and this is something that once you know it’s there, you don’t need to be reminded of it.

    I sent a PR and hope this helps.

    Mike

    Plugin Author Shea Bunge

    (@bungeshea)

    Thanks for this Mike, I’ve replied on the GitHub thread.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Feature Request – Codemirror search and replace’ is closed to new replies.