Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Keep Tabs" setting not working in Visual Studio 2019

I've been having a problem in Visual Studio 2019 where the program enters tabs as four spaces. This is annoying, since I have to hit backspace 4 times to erase an indent, and I need to use arrow keys 4 times to navigate an indent.

This used to work fine, but I had to uninstall and re-install Visual Studio to fix another problem (it kept running old versions of my code and wouldn't run the new version), and ever since then, I haven't been able to get it to work.

I went to settings, and selected 'keep tabs', but it still replaces it with four spaces every time i hit the Tab button. Interestingly, when I start a new line, I can navigate and backspace normally, but if I enter any more tabs, they are replaced with 4 spaces.

I've tried looking around, but I can't seem to find anything that addresses my issue. Can anyone help?

like image 642
Sanford Bassett Avatar asked Jan 15 '20 17:01

Sanford Bassett


1 Answers

Also note that Visual Studio 2019 now uses and prioritizes .editorconfig files over the Tools -> Options -> Text Editor settings. If you have tried the above answers and still cannot get your indent and tab settings to work, then look for an .editorconfig file anywhere in your project's directory structure.

For instance in my project Angular CLI created one for me when I initialize a new ng project in my .net Web API directory structure. All my *.ts files were not cooperating.

I had to edit the .editorconfig file to look like this in order to get 4 space indent and tab instead of spaces. Once I did that, Ctrl + K + D (reformat) started working again:

# Editor configuration, see https://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = tab
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true

[*.ts]
quote_type = single

[*.md]
max_line_length = off
trim_trailing_whitespace = false
like image 98
Ken Hadden Avatar answered Nov 15 '22 22:11

Ken Hadden