Skip to content

Add option to control tab width when viewing files

Tabulation character (0x09, \t) is always rendered with a width of 8 spaces, but many projects use 4 spaces for the width of tabs. It is important that when code is rendered in GitLab the tab sizes are consistent with how it is viewed in a local editor so that the code is easy to read.

Not sure if this is Firefox's default or if the highlighter sets this (Chromium does the same). Couldn't find a configuration for Gitlab (gitlab.rb, GUI or even CSS from 'rouge' library) nor for Firefox.

We should provide per-project configuration for tab width.

Proposal

We should use the established EditorConfig file to reuse the settings that are likely already in the repository and supported by major editors.

If a .editorconfig file is present in the repositories root, use the indent_size and tab_width to render the source code.

Links

https://editorconfig.org/#file-format-details

Edited by James Ramsay (ex-GitLab)