Search with ignore white space


#1

Often I’m working in Chrome and I copy the line of css from chrome into the find of sublime (or now atom) to find that line of code in the css).

Chrome automatically indents the css to make it look best however the actual css may have extra spaces or line returns.

So say I search for:

<li><a href"#">Test it</a></li></ul>

Atom says 0 results even though I can see it in the code. The reason being in the actual code it’s display as:

<li><a href"#">Test it</a></li>
</ul>

Is there a way to get search to find results and ignore spaces and line returns when not in text. That is search should respect the space between “Test” and “it” but should be insensitive to the spaces and and returns in the actual code since the code renders identically eitherway and is simply a styling choice. Also I realize this could be do with regex but that would defeat the point of saving time and being able to simply copy and paste a line of css from chrome inspector.

Or does anyone know of plugin to accomplish this?


#2

Jut yesterday I could have used this feature. I was searching for x = but my code had lines like these …

x   = 3
abc = 4

I used a regex /x\s+=/. In general you can always use a regex but a mode for ignoring spaces would be nice.

Of course the current finder is missing a zillion features like preserve-capitalization, showing lines around the result, etc…

My biggest complaint with the finder is that after you do a replace you lose the results and get the message no results found which is totally wrong.


#3

Yeah I hear ya Mark. While the Sublime Team couldn’t figure this one out, I’m far more confident Atom members will figure out a solution whether core or through a plugin. Would be incredibly helpful. Maybe the plugin behind the scenes would remove all white space do the search and return the results and then bring back the white space as it was before, or something. Lots of ways to go about it, but sadly I’m not one to be able to currently build it.

If anyone else has ideas on that matter would love to hear such as uses cases. For me regex is great for one of searches but not for searches that I simply need to disregard white spaces since I do it countless times per day.


#4

I think a service API that allows packages to register search-providers with the find-and-replace package would be nice. A search provider could be an extra toggleable button - just like the “toggle regex” etc. buttons in the find-and-replace panel - and a function that receives a piece of text, a string to search for and optionally a string to replace. Don’t know how this would be implemented though, what happens when multiple search-providers are activated at the same time etc…


#5

It would be much easier to use a regex search. That is a fundamental core operation.


#6

You would do either a union or intersection of results. Not sure which.