Skip to content

XrXr/vscode-tabs-are-two-indents

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tabs are Two Indents

A tab character means two indentation levels in some codebases; have Visual Studio Codde render it as such.

Demo

Why?

As of June 2022, the notion of indentation size is coupled with tab width in Visual Studio Code. Without any extensions, it's not possible to indent by 4 spaces but have tab characters render as wide as 8 spaces, for example.

There are many codebases where a tab character should render as two levels of indentation. The following are some examples:

There are two long-standing open features requests to separate indentation size from tab size, but there is no native support in the editor as of yet.

Limitations

Indent guides can be missing. While this extension makes the editor render tab indents at the desired width, it does not teach Code that one tab is two levels of indentation which require two levels of indent guides. You have the option to disable the guides by setting the following:

"editor.renderIndentGuides": false

Additionally, this extension does not change the width of tabs that are in the middle of a line. The rendered width of a tab is fluid and depends on the placement of the character within a tab stop. The editor itself is in the best position to calculate the correct width.

There are additional extensions available to work around these issues, but it would be better if Code could natively treat the tab size and indentation size as separate.

Maybe leaving comments in the feature requests could make the maintainers care more about this usecase?

Configuration

Take a look at package.json to see available settings and commands.