Closed XenHat closed 11 years ago
Mixing tabs and spaces in general is a really annoying and dangerous task for this very reason (and others).
Sublime Text allows you to specify whether it should use tabs or spaces for a tab/view. Did you set this accordingly?
I completely agree with you. However, I'm only a contributor, I didn't make the rules about the tabbing in this project. Even though I disagree with how they do it, I have to conform to it. And so far, Sublime doesn't give me much choice.
In short, the issue is that I have to combine both tabs and spaces and sublime replaces what I type by either tabs or spaces depending on the documented settings.
A friend told me about an undocumented(!) setting that seems to makes the trick:
"translate_tabs_to_spaces": false,
I think this option should be added to the default configuration (with a value of true, to keep the default behavior) with a warning about being not recommended.
Right now, the relevant options of my current config are:
"translate_tabs_to_spaces": false,
"translate_spaces_to_tabs":true,
"tree_animation_enabled": true,
"trim_automatic_white_space": false,
"trim_trailing_white_space_on_save": false,
"use_tab_stops": true,
"smart_indent": true
This is in the default configuration:
// Set to true to insert spaces when tab is pressed
"translate_tabs_to_spaces": false,
Anyway, this is what I meant when I talked about your tab settings. You can see and modify them when clicking on the status bar section.
All right. It also seems that the default configuration works as expected. I guess it was my fault for trying to "power-trip" Sublime while the default worked. I suppose I can close that.
I made a (short) video of the behavior I'm experiencing. https://dl.dropboxusercontent.com/u/7425443/Indent.mp4 The default settings doesn't seem to do what I wanted.
This looks indeed weird and might have something to do with the reindent
command.
Are the above settings the settings you use in the video? Because I can't seem to reproduce it. Maybe your full settings file might help.
For the recording of this video, the settings were, litterally,
{
"ignored_packages":
[
"Vintage"
],
"draw_white_space":"all",
}
and my package list is:
ApplySyntax.sublime-package
BracketHighlighter.sublime-package
CMake.sublime-package
Commitment.sublime-package
Dotfiles Syntax Highlighting.sublime-package
FavoriteFiles.sublime-package
GitGutter.sublime-package
Highlight Whitespaces.sublime-package
INI.sublime-package
JSONLint.sublime-package
JavaScript Refactor.sublime-package
Molokai-Pastel.sublime-package
Package Control.sublime-package
Sublimerge Pro.sublime-package
Theme - Soda.sublime-package
Trimmer.sublime-package
---- Below are not listed in the Installed Packaged folder ---- LSL (this version: https://github.com/Makopo/sublime-text-lsl) SublimeCode Intel
EDIT: I tested again with this:
{
"ignored_packages":
[
"Vintage"
],
"draw_white_space":"all",
"translate_tabs_to_spaces": false,
"translate_spaces_to_tabs":true,
"tree_animation_enabled": true,
"trim_automatic_white_space": false,
"trim_trailing_white_space_on_save": false,
"use_tab_stops": true,
"smart_indent": true
}
And the behavior is the same.
I did further testing... It behaves (somewhat) correctly in these type of files
but so far, it aggressively replaces tab key presses with spaces in:
To clarify this: it does insert the equivalent of a "tab", but it inserts 4 spaces characters instead of the "tab" one. This is problematic.
I found a solution; unckecking View menu -> Indentation -> Indent Using Spaces. This issue apparently has been ignored, so I think I should stop caring.
This is specially annoying when using a modification system that's based on xml and finding/replacing/adding/etc, a tab is very different from 4 spaces in a find scenario...
vqmod ocmod opencart
Cheers!
@XenHat
I found a solution; unckecking View menu -> Indentation -> Indent Using Spaces. This issue apparently has been ignored, so I think I should stop caring.
god you saved my life
I found a solution; unckecking View menu -> Indentation -> Indent Using Spaces. This issue apparently has been ignored, so I think I should stop caring.
This was very very helpful. Not sure why the editor adds spaces when I press tab. Went through the settings and it seems everything is set up correctly and it should insert tab instead of 4 spaces.
This is an old thread, but I was able to find more details.
(1) When Sublime (build 4107) opens a text file and finds a line starting with a space, but no line starting with a tab, it automatically turns on the setting "View / Indentation / Indent using spaces".
(2) With the setting "View / Indentation / Indent using spaces" turned on, every tab is replaced by spaces, even in the middle of a line.
I think (2) is the more serious problem and possibly it did not occur before build 4107, as I only started seeing it after the update. On the other hand, because of (1) the solution of XenHat has to be applied every time you open a file. Or, you can override another setting:
"detect_indentation": false
which seems to prevent (1) and therefore does not trigger (2), at least in my case.
ST3 also translates tabs to spaces in the middle of lines.
I work on a project where whitespaces are very important since there's a lot of forks and repositories for the same project.
My problem is that sometimes the way tabs are done isn't immediately obvious for people like me who doesn'T use an IDE that 'corrects' or masks those weird whitespace. The way it works has something to do how the parent compagny's Macintosh tools work.
I looked around in the configuration and there seems to be no way to avoid agressively replacing tabs with spaces. let's take this example:
On the left is what Sublime does no matter what I do, and on the right is the original tabbing. Even if I copy the spacing from the right, it will paste space characters on the left. This is terribly annoying, because I can't fix it manually and my co-workers are 'friendly yelling' at me because it causes horrible merge conflicts.
I really like using Sublime Text, but this behavior is causing me so much issues I can't really recommend it to other people for a programming environment... :(
Related to issue 95