Creating macros in intellij

I am trying to create a macro that takes a selection of text and runs some find / replace on it using a regular expression. I recorded this macro in intellij, but when I run it, all I get is a search / replace dialog. Search / replace is not performed.

Is anyone lucky with creating find / replace macro in intellij?

+4
source share
3 answers

I cannot make the macro find / replace work, but I can give you two things that can solve your problem:

  • If this is only a few places / times, you need to do this to find / replace has a memory of earlier replacements (down arrow in the search / replace fields).

  • Write a plugin (yes, seriously, it’s not at all difficult) to do it for you. I was surprised how easy it was, although the documentation could be improved.

And the bonus way to do this, I just thought:

  • Open the file in the Emacs entry, replacing the macro (or write the elisp function to do this), so I would have done it until I found out how easy it was to create Idea plugins.
+1
source

This is apparently a long-standing bug in IntelliJ. One way to solve this problem was as follows:

  • Install the IdeaVim plugin.
  • When recording a macro that needs to be searched, enable Vim mode (Tools β†’ Vim Emulation) during the macro, place the cursor using standard Vim measures, turn off Vim mode.

In general, Vim emulation can be very convenient for IntelliJ macros.

+1
source
-4
source

All Articles