Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace with newline works only when regex mode is on #11237

Closed
bootstraponline opened this issue Aug 30, 2016 · 12 comments
Closed

Replace with newline works only when regex mode is on #11237

bootstraponline opened this issue Aug 30, 2016 · 12 comments
Assignees
Labels
editor-find Editor find operations feature-request Request for new features or functionality

Comments

@bootstraponline
Copy link

bootstraponline commented Aug 30, 2016

  • VSCode Version: 1.4.0
  • OS Version: OS X 10.11.6

Steps to Reproduce:

  1. Find text and replace with \n
  2. Literal \n is used instead of a newline

Input

input_vscode

Actual

actual_vscode

Expected

expected_vscode

Regex mode works as expected however I'd rather not have to define a regex.

@dbaeumer dbaeumer added editor editor-find Editor find operations labels Aug 30, 2016
@alexdima
Copy link
Member

When the regex flag is on, then we parse the replace string:

  • \n => LF
  • \t => TAB
  • \\ => \

So you would expect that we should always parse the replace string... That would make sense, my only concern is that it might cause some grief to folks that got used to it being "literal" when not in regex mode.

@alexdima alexdima added this to the September 2016 milestone Aug 31, 2016
@alexdima alexdima added the feature-request Request for new features or functionality label Aug 31, 2016
@bootstraponline
Copy link
Author

my only concern is that it might cause some grief to folks that got used to it being "literal" when not in regex mode.

If they want the literal, I think \\n is a better syntax. This allows both use cases.

@hashhar
Copy link
Contributor

hashhar commented Sep 9, 2016

I would like to chime in with how some other editors handle this.

The most elegant method is used by vim. They have a special prefix which tells the search to treat special characters as special. But by default they treat all characters as literals.

Atom also treats as literal unless you turn on regex mode and emacs behaves the same way. So I think that the current way is more common to the users and should be left as it is.

Just my 2 cents.

@alexdima
Copy link
Member

So now I'm in a pickle :) ... I don't have a preference either way and it looks like editors have done it before both ways.

@bootstraponline
Copy link
Author

I think it's weird to only support literals in regex mode when the user does not want to define a regex. Maybe make it an option and keep the existing behavior as the default?

@hashhar
Copy link
Contributor

hashhar commented Sep 12, 2016

I agree with what @bootstraponline is saying. Ensuring that the new behaviour doesn't differ much from current behaviour is important from a user's perspective. Not everybody reads release notes.

@alexdima alexdima modified the milestones: Backlog, September 2016 Sep 27, 2016
@rebornix rebornix self-assigned this Apr 28, 2017
@alexdima alexdima changed the title Replace with newline doesn't work Replace with newline works only when regex mode is on Nov 24, 2017
@alexdima alexdima removed their assignment Nov 24, 2017
@alexdima alexdima removed the editor label Nov 24, 2017
@rebornix rebornix removed their assignment Sep 18, 2018
@sebas-w
Copy link

sebas-w commented Feb 15, 2019

Is there any idea of when/if this may be added or altered in Visual Studio Code? looks like it's going on 2 years now so my hope is low.

@bootstraponline
Copy link
Author

I think it'll be up to someone from the community to send a pull request. 🙂

@mbomb007
Copy link

mbomb007 commented Oct 13, 2020

There's a similar issue in the Backlog Candidates. Please upvote it (and share it) so this gets fixed! #31449

@rebornix rebornix modified the milestones: Backlog, Backlog Candidates Nov 2, 2020
@rebornix rebornix self-assigned this Nov 2, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Feb 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
editor-find Editor find operations feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

8 participants
@rebornix @bootstraponline @dbaeumer @alexdima @hashhar @mbomb007 @sebas-w and others