XVimProject / XVim

Xcode plugin for Vim keybindings
MIT License
5.16k stars 595 forks source link

Replace capture group not work #720

Open MellongLau opened 9 years ago

MellongLau commented 9 years ago

I try :%s/k(.+?)e/$1d/ for

extern NSString * const kTaskTitle; extern NSString * const kTaskIsCompleted; extern NSString * const kTaskCompletedDate;

but the result is

extern NSString * const $1d; extern NSString * const $1dted; extern NSString * const $1dtedDate;

capture group not work.

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Zverik commented 8 years ago

Confirmed, $1 does not work. How do people use xvim without working regexps?..

bbudzon commented 8 years ago

I just ran this test case through vim and it failed to pattern match.

Zverik commented 8 years ago

Tested on %s/(s)td/$1ad/g and it didn't work, got a full code of $1ad.

bbudzon commented 8 years ago

Are you sure you guys shouldn't be escaping the parenthesis?? And isn't it "\1" not "$1"?

In vim (not XVim or Xcode), /(s)td/ will only match the string (s)td. /\(s\)td/ on the otherhand will only match the string std storing the s off in the first register for later use via \1 (not $1).

Zverik commented 8 years ago

XVim uses ICU regexps. And of course I tested escaping things and using \1. Ended up doing all replacing in vim.

bbudzon commented 8 years ago

I never knew this! Good to know!! It would def be nice if we could get this working as I used registers a LOT in vim...

99arobe commented 8 years ago

Just found this thread. This would be a great feature to implement. Is there any plan to put this into a release soon?