Sublime Forum

Code Folding Using Spaces Instead of Tabs

#1

Hi, I was wondering how to make Sublime fold code that’s indented using spaces (4 spaces, to be precise) instead of at every tab?

The engine I use doesn’t allow tabs, only spaces.

Thanks for any help! Much appreciated.

0 Likes

#2

Seems to work fine for me (I’m using ST3).

I agree that TABs are evil. We don’t permit them around here.

0 Likes

#3

Thank you for the response! I must be doing something wrong.

For some reason I can fold this, when it’s left aligned:

label 1: code code code

but as soon as I have something like this (indented by 4 spaces):

label 2: code code code

Sublime doesn’t recognize label 2 as foldable. Only if I change everything to TABS does it allow me to fold label 2.

0 Likes

#4

Hmm…I am unable to reproduce your problem.

0 Likes

#5

Yikes, I apologize for being unable to describe my problem properly (still new to coding)!

You know the fold buttons that show up along the left margin, in the gutter with the line numbers? They only show up for the left-most code blocks.

For everything else I have to do manual folds, which is rather inconvenient for me because as soon as you unfold them they disappear. (And you have to fold them anew each time.)

I would really like to find a way so those fold buttons show up for ALL indented code that uses spaces (instead of tabs).

Anyway, thank you for your replies bphunter1972. I appreciate that you attempted to try and comprehend my ill-described issue!

0 Likes

#6

Spaces and tabs both work for me @memomo. I think there is something funny with your setup.

0 Likes

#7

Thanks for your reply, faceless user! That’s helpful to know. I’ll try disabling all my packages, fiddling with my configuration and see what happens.

0 Likes

#8

I am experiencing the same issue.

The fold arrow in the gutter doesn’t have arrows for all indented elements in HTML, only a few:

<!-- Nav -->
  <nav class="navbar">
    <div class="container">
 V     <div class="row">
        <div class="col-sm-22 col-sm-offset-1 col-lg-18 col-lg-offset-3">
          <ul class="nav navbar-nav">
            <li><a href="#">Link1</a></li>
            <li><a href="#">Link2</a></li>
            <li><a href="#" class="brand"><img src="images/brand.png"></a></li>
          </ul>
        </div>
      </div>
    </div><!-- /.container -->
  </nav>

It only shows an arrow where I’ve marked it with a V. This is with reindenting and — “tab_size”: 2, “translate_tabs_to_spaces”: true — in my user settings.

Is anyone else experiencing this? I have the fold arrows set to always show and it’d be so much faster to be able to collapse each respective HTML element when necessary.

Thanks!

0 Likes

#9

Have had this issue ever since i started using sublime over a year ago.
Two screenshots to show the issue. Notice that with space indentation, only the node touching the gutter gets a fold icon.

TABS

SPACES

0 Likes

#10

Try changing your tab width to 2. It uses that for placing indent guides and I believe for folding (also for inserting spaces with the tab key).

0 Likes

#11

It is set to two.

0 Likes

#12

Hello I had the same issue and I solved it by changing my font.

check this thread:

0 Likes