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 tabulation not working #26

Closed
letatas opened this issue Mar 25, 2015 · 18 comments
Closed

Replace with tabulation not working #26

letatas opened this issue Mar 25, 2015 · 18 comments
Labels

Comments

@letatas
Copy link

letatas commented Mar 25, 2015

Hello,

I'm trying to replace spaces with tabs, but unfortunately this doesn't work:

"tweaker_space_to_tab": {
                    "find" : " ",
                    "replace": "\\t"
                }

I've also tried "\t" which also failed.

Any idea?
Thanks in advance.

@facelessuser
Copy link
Owner

The reason this isn't working for you is because you must currently have indent with spaces enabled in your view. Sublime, when a tab is inserted at the beginning of a line, will convert it to spaces. If you turn off the indent with spaces settings in your view, it should work fine.

Now, the real question is if there is a way for me to always insert without triggering this behavior; I don't know yet.

@facelessuser
Copy link
Owner

I guess it might be possible for me to check the convert tabs to spaces settings, and briefly disable it while I insert and restore the setting after. I will look into that when I have time.

@facelessuser facelessuser added P: maybe Pending approval of low priority request. Priority - Low T: enhancement Enhancement. and removed Question labels Mar 25, 2015
@letatas
Copy link
Author

letatas commented Mar 25, 2015

Thanks for looking into it. In fact, even the characters not located at a beginning of a line are replaced by spaces instead of tabs.

But what is strange is that when I use the built-in find and replace function of Sublime Text, if I set the replacement to be \t, it does it the way it should, by inserting tab characters and not spaces. Even with the "indent with space" opt-in.

@facelessuser
Copy link
Owner

Yeah, turns out that "indent with spaces" option converts tabs mid line too.

So as to why it standard find and replace doesn't have this issue, it is because I am going through the API. And the View.replace replace method seems to respect the "indent with spaces" option. That is unfortunate, but not impossible to work around. I just didn't realize it was an issue until now.

@letatas
Copy link
Author

letatas commented Mar 25, 2015

You're not to blame! But that's true that for me, your excellent tool is used to sequence "find and replace" instead of the built-in one, that includes righteously the tab character.

Anyway thanks again for looking into it. And sorry for the "inception" of this issue in your mind...

@facelessuser facelessuser added T: bug Bug. Severity - Minor and removed T: enhancement Enhancement. P: maybe Pending approval of low priority request. Priority - Low labels Mar 25, 2015
@facelessuser
Copy link
Owner

Fix is found here c06390a. It will be included in the next release.

@letatas
Copy link
Author

letatas commented Mar 26, 2015

Yeah that's great! Thanks alot, when do you think the next release will be?

@facelessuser
Copy link
Owner

Done

@letatas
Copy link
Author

letatas commented Mar 26, 2015

Thanks a lot! But Package Control is stuck with v.1.9.0, do you know why ?

@letatas
Copy link
Author

letatas commented Mar 26, 2015

Damn it! I'm using Sublime Text 2, and I've just understood what ST3 stands for in front of the version. Woe with me!

@facelessuser
Copy link
Owner

You should upgrade to ST3 😉. It's just too much work for me to support all the plugins I have, and then do it for 2 separate versions of ST. I don't even use ST2 anymore.

With that said, the needed changes are found right there in the commit. You can modify it yourself for ST2 if you are resistant to upgrading. I don't mind people backporting ST3 features to the ST2 branch, I am just not going to personally do it anymore.

@letatas
Copy link
Author

letatas commented Mar 26, 2015

I understand, unfortunately ST3 being still in beta phase, I can't afford to switch in a production environment. But as soon as it's officially released, I'll upgrade. Meanwhile, I'll try to backport your commit.

Thanks again.

@letatas
Copy link
Author

letatas commented Mar 26, 2015

Backporting successful! Many thanks.

@facelessuser
Copy link
Owner

If you have it all working, I would accept a pull request to make it official. I accept backport pull requests for ST2, I just won't accept new features or changes on 2 unless it is first accepted and implemented on the main branch.

letatas added a commit to letatas/RegReplace that referenced this issue Mar 26, 2015
@letatas
Copy link
Author

letatas commented Mar 26, 2015

Done

@facelessuser
Copy link
Owner

@letatas Did you pull request it on your own repo? I don't see the pull request on my repo.

letatas added a commit to letatas/RegReplace that referenced this issue Mar 26, 2015
facelessuser added a commit that referenced this issue Mar 26, 2015
@letatas
Copy link
Author

letatas commented Mar 26, 2015

Ooops... My bad... It's late over here... It should be ok by now.

@facelessuser
Copy link
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants