Sublime Forum

Spurious tabs appearing

#1

I noticed recently that a lot of my code has a bunch of redundant tabs at the end of the line and I was sure I didn’t put them there :smile: I’ve tracked it down to a particular way of duplicating a line. (admittedly this is a bit of a bizarre way of duplicating a line but still)

Firstly, I should say I have the default settings of ‘Don’t replace tabs with spaces’ and have tabstop set to 4.

Take a line that is tabbed in two tabs from the left-hand edge. Press to go to the end of the line. Hold and press so that you select everything up to the beginning of the line but not the two tabs. to copy the line, to insert a blank line below and return the cursor to the far left edge, then to paste the new line. You should see that the line appears to have two tabs at the end of it. The number of tabs at the end is identical to the number of tabs at the beginning of the copied line.

0 Likes

#2

Yeah, this is the auto indentation at work, for better or worse.

I also end up with unwanted whitespace that was inserted by the auto indenter, and it’d be nice to have a clean way to get rid of it. Some editors delete the automatically inserted whitespace if you do anything other than typing after pressing enter, but I’m not terribly keep on this, due to it being so stateful (i.e., it would then be required to track which regions of text have been inserted due to auto indent).

Another possible option would be to automatically trim trailing whitespace on any line you edit, unless you’re editing at the end of the line. Not sure if this would have some unintended consequences though.

0 Likes

#3

Ah, I see, yes that makes sense. Like I say, it is a bizarre way of working on my part and I don’t usually do it, but I wanted to track down the cause.

0 Likes

#4

I just trim all trailing space on save… I hate them >.<

0 Likes

#5

I can’t think of an unintended consequence of trimming trailing spaces/tabs from lines… but I guess that’s the nature of unintended consequences :smiley:

0 Likes