4

I'm beginning to use IntelliJ with the vim plugin, and found that commands as simple as

/case (.*)

fail to return any results. Of course, that's not a very useful command. I'd like to reverse the order of all of the elements of my table by executing

:'<,'>s/case (\w*): return (\w*);/case \2: return \1;/

but that also failed to match anything. I tried a few different search regexes and all of them worked as long as there were no capture groups.

Does IntelliJ Vim support capture groups like these? Are there special characters I need to escape to get it to work? I know the builtin search and replace gui lets you do logic with backreferences, but I'd like to do my work right from the command line.

Alex Sage
  • 45
  • 1
  • 4

1 Answers1

7

This wouldn't even work in Vim to begin with.

(\w*) is not a capture group; it will match a literal opening parenthesis, followed by any number of any keyword character, followed by a literal closing parenthesis.

\(\w*\) is an actual capture group… which will work both in Vim and in IdeaVim.

romainl
  • 186,200
  • 21
  • 280
  • 313