What aspects of Vim does Obsidian support? Does it support capture groups?

What I’m trying to do

I have been using Vim motions and also some Vim commands, especially substitution using :%s/.../.../g.

It seems that some features of Vim are not supported, though.

For example, normally you can use escaped parentheses to capture some characters, and re-use them with the \1 syntax:

:%s/\(\w\)\(\w\w\)/\1y\2/g

But Obsidian does not treat the escaped parentheses as capture groups.

If you try this:

%s/./\1y/g

it does not treat \1 as a special syntax referring to whatever . matched. It just substitutes all characters with literally ‘\1y’.

So it seems like capture groups aren’t supported in whatever version of Vim functionalities Obsidian is using.

Why is this? Is there a specific name for the subset of Vim functionalities Obsidian uses? Is there any other way to do this in Obsidian, or a different Vim syntax?

Things I have tried

I’ve also tried using the \v flag to avoid the need for escaping, but it doesn’t change the fact that \1 isnt even recognized as a special substitution character.

I got the answer from Claude 3.5 Sonnet:

Obsidian uses CodeMirror’s Vim mode, which implements a subset of Vim functionality. While it includes many common Vim motions and commands, it doesn’t support the full regular expression syntax that Vim proper does, including capture groups.

The search and replace functionality in Obsidian’s Vim mode uses JavaScript’s regular expression engine rather than Vim’s. However, you can still achieve capture group functionality using JavaScript regex syntax. Instead of Vim’s \1, you would use $1:

:%s/(\w)(\w\w)/$1y$2/g

Note a few key differences:

  • Use regular parentheses () instead of escaped parentheses \(\)
  • Use $1, $2 etc. for backreferences instead of \1, \2
  • The regex syntax follows JavaScript conventions rather than Vim’s