`:s[ubstitute]` not handling backslashes correctly
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 15.2k
- Forks
- 1.5k
- Avg merge
- 3d 18h
- Merged PRs (30d)
- 6
Description
Describe the bug
A clear and concise description of what the bug is.
I have a line of text like C:\\Program Files\\Microsoft and I want to replace all double backslash (\\) to single backslash (\), so I tried below command line substitution:
:s/\\\\/\\/g
or
:s/\\\\/\/g
or
:s/(\\)\\/$1/g
The first command did nothing, and so I tried the second one, which replaced double backslash (\\) to single slash (/). Only the third one worked as what I expected.
Both 1st and 3rd command worked well in gVim 8.2.12 (though need to replace $1 to \1).
To Reproduce
Steps to reproduce the behavior:
- Go to '...'
- Click on '....'
- Scroll down to '....'
- See error
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
If remapping-related, please attach log output: https://github.com/VSCodeVim/Vim#debugging-remappings.
Environment (please complete the following information):
- Extension (VsCodeVim) version:1.20.2
- VSCode version:1.56.0
- OS: Windows 10
Additional context
Add any other context about the problem here.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the :s[ubstitute] command entry point and reproduce the three substitutions described in the issue using VSCodeVim on Windows. Trace how backslashes and replacement references are parsed, then verify that replacing double backslashes with single backslashes behaves as expected without changing them to slashes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript, vim
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100