Twitter Email
subspace (/ˈsʌbspɛɪs/)
A Jekyll playground site

Quick solution to hide the horizontal scroll bars in Sublime Text

Author: Admin
Title: Hide the horizontal scrollbars in Sublime Text 4
Language: en-US
Number of words: 501
Created: 19:15 on Wednesday, 03. November 2021
Modified: 19:15 on Wednesday, 03. November 2021
Keywords: sublimetext, sublime, theme, scrollbars
Excerpt:

A Simple way to hide the horizontal scrollbars only while keeping the more useful vertical bars. This is for Submlime Text 4 on Linux, but may work with other setups.

Tags: sublime
Page layout: nonav
Last modified: , 501 Words
19:15 on Wednesday, 03. November 2021 | by Admin in Sublime

I know, there is the overlay_scroll_bars setting for automatically hiding scroll bars while they are not in use and it’s doing a good job for most, but some people, including myself, would prefer to keep the vertical and hide only the horizontal scroll bars. This is only possible by modifying the Theme, as there are no special settings for it. {:dc}

This method works fine on Linux with the GTK theme. So far, this is the only tested environment, so be prepared for some issues on other systems. Also pay attention the comments below about the content_margin values. You may have to do small modifications on the example code to make it work on your setup. This method is also only tested with Sublime Text 4’s default Themes (dark, light and adaptive). It may or may not work with older legacy themes (it likely won’t).

In order to apply this fix, you have to edit your Theme by first selecting Preferences⟶Customize Theme (remember, Theme not Color Scheme). You’ll get the familiar two-pane view with the original file in the left and your customization options in the right pane. Unless you have already customized something, the right pane should be empty and look about like this:

Code: (click to select all)
1
2
3
4
5
6
7
8
9
10
// Documentation at https://www.sublimetext.com/docs/themes.html
{
  "variables":
  {
  },
  "rules":
  [
    
  ]
}

The relevant section is the rules part of the file. You have to insert the following JSON code below between the square brackets.

Code: (click to select all)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// hide the scroll puck for horizontal scroll bars
{
  "class": "puck_control",
  "attributes": ["horizontal"],
  "layer0.opacity": 0
},
// hide the scroll bar background itself.
{
  "class": "scroll_bar_control",
  "attributes": ["horizontal"],
  "content_margin": [0, -4], // you have to experiment with these values
  "layer0.opacity": 0.0,
  "layer0.tint": "#000" // optional
}

Note line number 11. Depending on your operating system and theme, you may have to experiment with the content_margin values to hide the scroll bar by simply using a negative margin. Also, line number 13 is optional. Since we are totally hiding the scroll bar, a color should not be necessary, but you can use it for debugging. For example: You may set it to red and if some red line appears where the scroll bar should be, it will tell you the content_margin values are wrong.

Once done, verify for correct JSON syntax and save the right part of the theme file. Sublime Text should now immediately reload the file and your horizontal scroll bars in text views should disappear.

Here is an additional hack to hide the Sidebar scroll bar.

The side bar doesn’t really need a scroll bar in my opinion. So here is an optional hack for your theme customization to remove it. Like above this needs to go into the rules section of your theme customization.

Code: (click to select all)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// sidebar scroll bar, hide the puck
{
  "class": "puck_control",
  "parents": [{"class": "sidebar_container"}],
  "layer0.opacity": 0
},
// sidebar scroll bar, hide the backgrond
{
  "class": "scroll_bar_control",
  "parents": [{"class": "sidebar_container"}],
  "content_margin": [-4, 0], // you have to experiment with these values
  "layer0.opacity": 0.0,
  "layer0.tint": "#000" // optional
},

Again, you may have to tweak the value in line number 11 for best results.