Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Find and replace auto indent for new lines. #1145

Open
tocruise opened this issue Nov 16, 2020 · 1 comment
Open

Find and replace auto indent for new lines. #1145

tocruise opened this issue Nov 16, 2020 · 1 comment

Comments

@tocruise
Copy link

Summary

When doing a find and replace - a find on a single line, to replace it with multiple other lines - it would be nice if Atom automatically indented the new lines to match the style of surrounding/preceding lines. Similar to how when you go onto a new line, it automatically knows where your cursor should be. It would be nice if this applied to replaces also.

I always have an awful time trying to explain what I mean, so if this isn't clear then please refer to the Additional context section below.

Motivation

In each file, each line of my code has a varying number of tab-indentations, as I'm sure everyone's code does. It seems weird to me that nobody has ever wanted to do a find-and-replace on multiples lines of varying indentation, without having to manually specify a number of tabs.

Describe alternatives you've considered

I've scrolled through all of the issues on this Git and found nothing similar to what I'm trying to do. I've also flicked-through the community packages, and found nothing that works to achieve this.

Additional context

Here's what currently happens...

This is my code:

image

I'd like to add a comment title line above the var output = get_output(data); (the highlighted line). Instinctively the best way to do this, would be to use regex in the find and replace like so:

Find: var output = get_output(data);
Replace: /* Get response */\r\n\r\nvar output = get_output_new(data);

The reason I'm using find and replace, and the reason why I can't just use \t to add the correct number of tabs, is because this line of code exists in many files, all with different amounts of indentation. So although, in this specific case, \t\t\t\t would be the correct number of tabs to match the indentation, it wouldn't match in other files - 4 tabs may be too many or too little.

Here is what the result should look like after running the find and replace:

image

But, instead it looks like this:

image

Like I said, without manually adding \t I don't see how I'd be able to get this to look how I desire.

@UziTech
Copy link
Contributor

UziTech commented Nov 16, 2020

This issue should be moved to the https://github.com/atom/find-and-replace repo

@sadick254 sadick254 transferred this issue from atom/atom Nov 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants