Redefine tab as 4 spaces in Gitlab CE

As of February 2021, this has not been addressed. One can check the current GitLab issue for progress, but in the meantime, this comment on the thread offers a solution via creating a UserScript via Greasemonkey / Tampermonkey with this script:

// ==UserScript==
// @name GitLab Tab Size
// @version 1
// @include https://gitlab.com/*
// @grant none
// ==/UserScript==

const TAB_SIZE = 2

window.addEventListener('load', function() {
  const styleElement = document.createElement('style')
  styleElement.innerHTML = `
    .diff-content, pre.code {
      -moz-tab-size: ${TAB_SIZE};
      tab-size: ${TAB_SIZE};
    }
  `
  document.head.appendChild(styleElement)
})

Credit to Brendan Gadd from that thread.


Yeah, gitlab uses browser CSS property tab-size which default value is 8. There's a bug discussion about this here: https://gitlab.com/gitlab-org/gitlab-ce/issues/2479 You can change gitlab CSS and you'll have what you want.


Go to Settings -> Preferences -> Behavior and set Tab width

Tags:

Gitlab