guillermooo / Vintageous

Vi/Vim emulation for Sublime Text 3
http://guillermooo.bitbucket.org/Vintageous/
Other
1.64k stars 115 forks source link

Replace every line with quotations doesn't work #1080

Closed jasjuang closed 7 years ago

jasjuang commented 7 years ago

Suppose I have text below

how are you

after typing

:%s/^\(.*\)$/"\1"/g

it will return

"how" "are" "you"

in vim but executing this line in vintageous yields no change

deconvolved commented 7 years ago

Vintageous uses the Python regular expression engine which, unlike vim, does not use escaped parentheses for capturing. Try instead

:%s/^(.*)$/"\1"/g

I don't believe there are plans to ever make Vintageous RE match exactly that of vim.

jasjuang commented 7 years ago

Thank you for your response, I tried your proposed command but it does nothing for me, does it work for you?

deconvolved commented 7 years ago

It does work for me, however I forgot to account for a line anchor bug that has been fixed in master but is still present in the latest official release. It causes improper handling of ^ and $. For example, if you instead try :%s/(.*)/"\1"/g, I think you will get the expected result for the example you provided. Not very helpful if you need the anchors, but it demonstrates the difference in how parentheses are used for capturing.

For the moment, if you want the anchor fix, you will need to build Vintageous from source. There are instructions for doing so here.

jasjuang commented 7 years ago

The solution without the anchor actually works for me... thanks a lot!

Is there any plans on updating the latest change to sublime package?