Tabify all files of project



I am using the package . Is there a way we can convert all the spaces to tabs for the project?

I did tried using git settings , but some how the spaces were not converted to spaces with that technique also.


You can open find-in-project (ctrl-shift-f), search for occurrences N consecutive spaces, where N is the project’s tab size, and replace them with a hard tab. To do this, you can turn on regex mode in the find-and-replace panel, put the number of spaces in the search box and put \t in the replace box


Awesome dude!. I wonder why I never thought of it. Thank you.


I’m sorry @olmokramer, but I think that’s too simplistic. If the tab size is 4:

    b  In this line, the first four spaces become a tab
a   b  In this line, the first three spaces become a tab
aa  b  In this line, the first two spaces become a tab

I wish it was that easy…


Why would find-and-replace match 3 or 2 spaces when I search for 4 consecutive spaces?


I see. I apologize, brain fart. Your idea was to replace spaces with tabs at the beginning of a line. At the beginnings of lines, it works.

Hm. But then, you are also replacing some spaces with tabs in the middle of lines. Let’s say tab width is four, and you see this (showing digits in second line to make it clearer):

aa        bb

The above line contains eight spaces, so you replace the first four with a tab and then the second four with a tab. But actually, the first tab only advanced two characters, then the second tab advances four characters, for a total of six.

So now you have broken the visual appearance of lines that had lots of spaces in them.


Converting whitespace the way people expect has a few non-obvious edge cases. You can take a look at the specs for my tabs-to-spaces package for a list.

I added an Issue for the feature here:

I’d be open to a pull request for adding this feature (convert all files in a project on command). I’m not sure when I’ll be able to get to it at the moment, but it sounds like something that would be useful more than the occasional one-off.


Fair enough… But when you can do your whole project in 1 go and then have to adjust for these edge cases, I think my answer was decent enough :stuck_out_tongue: Thanks for getting me acquainted with some of those edge cases, though, it’s important to keep the big picture in mind :smile: