I'm using the latest VS Community. Let's say my cursor is right here:
When I press delete, a space is deleted. Is there a way to make it so four spaces are deleted instead? That's the way it works in a lot of other editors, including VS Code.
When I press delete, a space is deleted. Is there a way to make it so four spaces are deleted instead? That's the way it works in a lot of other editors, including VS Code.
Many editors including Visual Studio (VS), can be configured to show tab characters either as tabs or rendered to a fixed number of spaces, say four (4). (there are reasons for this, each with their own pros and cons - a subject for another day)
I suspect what you were seeing in VS Code (VSC) was a file that contained a tab character and VSC is showing tabs as tabs (instead of spaces) in the text editor. Hitting Delete over a tab makes it look like four spaces get deleted in one go!
However, your installation of Visual Studio however might be set to show tabs as spaces (I forget which is the default) which explains why you have to hit Delete more than once over an area of indentation.
You can confirm how tabs are shown in VS by selecting Edit.Advanced.View White Space (I like to keep it on). If you see little arrows it means a tab character is present. If you see dim period symbols its a space. In the screenshot below we can see a file with tabs rendered as spaces.
If tabs are rendered as spaces in VS that explains why you have to press the key four times.
You can control whether you want to always have tabs or spaces by selecting Tools.Options.Text Editor.C#.Tabs (assuming the file is C#)
Once this is setup "tabs" will either be tabs or 'n' number of spaces. However this only applies for new documents and VS generally doesn't auto-tabify-on-save.
Now it would be rather tedius to go through every file, manually flip everything to tabbed format so luckily VS has a rather neat feature to convert a file to tab or spaces based on your options:
The only built-in way to delete spaces just like they were tabs is to shift-TAB. Otherwise there is a plug-in called TabSanity that does what you want: https://marketplace.visualstudio.com/items?itemName=jedmao.TabSanity-10817
Turning on Visual Studio's "View White Space" (toggle with CTRL-R, CTRL-W) always shows what's in the file; it never "renders" tabs as spaces or vice versa.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With