visual-studio 使用制表符作为空格时删除制表符

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3086289/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 12:08:31  来源:igfitidea点击:

Deleting tabs when using tabs as spaces

visual-studiotabsspacestyping

提问by identitycrisisuk

I know that the general tabs vs spaces thing is as old as the hills and mostly comes down to personal preference/sticking to the style of your team, I just wanted to ask a practical question about using spaces in Visual Studio. There are certain things about tabs that bug me and I wouldn't mind changing to spaces while we're a small team. It would be no different for writing the code in the first place but would mean you'd have to delete/backspace 4 times where I'd previously press it once.

我知道一般选项卡与空格的事情与山丘一样古老,主要归结为个人喜好/坚持团队的风格,我只是想问一个关于在 Visual Studio 中使用空格的实际问题。关于选项卡的某些事情让我感到困扰,当我们是一个小团队时,我不介意更改为空格。首先编写代码并没有什么不同,但这意味着您必须删除/退格 4 次,而我之前按过一次。

Is there any easy way of deleting tab sized amounts of spaces easily (other than dragging with the mouse etc.) or if you've gone through the changeover yourself is it something that eventually doesn't bother you at all?

是否有任何简单的方法可以轻松删除选项卡大小的空格量(除了用鼠标拖动等),或者如果您自己进行了转换,它最终不会打扰您吗?

回答by Forgotten Semicolon

In Visual Studio, use Shift-Tab. This will go back one tab-stop, even when using soft tabs.

在 Visual Studio 中,使用Shift-Tab. 这将返回一个制表位,即使在使用软制表符时也是如此。

回答by jedmao

I've been plagued by the same issue for years. Finally, I did something about it. Let me officially announce version 0.1.0 of the TabSanity Visual Studio extension for VS 2012.

多年来,我一直被同样的问题困扰。最后,我为此做了一些事情。让我正式宣布VS 2012TabSanity Visual Studio 扩展的0.1.0 版。

It doesn't just stop at backspaces. It handles the delete key as well as arrow key navigation. Mouse interactions planned for near-future development.

它不仅仅停留在退格符上。它处理删除键以及箭头键导航。计划用于近期开发的鼠标交互。

There are some minor bugs I still need to resolve, but the groundwork is laid and I'm making steady progress. It's an open source project, so feel free to contribute on GitHub.

我仍然需要解决一些小错误,但基础已经打好,我正在稳步前进。这是一个开源项目,因此请随时在 GitHub 上做出贡献

回答by Justicle

In Visual Studio 2015

在 Visual Studio 2015 中

  1. Open file.
  2. Select all lines you wish to modify (or CTRL+A for entire file).
  3. Choose Edit->Advanced->"Untabify selected lines"
  1. 打开文件。
  2. 选择要修改的所有行(或 CTRL+A 对整个文件)。
  3. 选择 Edit->Advanced->"Untabify selected lines"

回答by Task

Yes, there's a very easy way.
You set your Visual Studio options (Tools/Options/Text Editor) to use spaces instead of tabs and then you open a source file and Ctrl-E,D (Edit/Advanced/Format Document) and it will convert them all for you!

是的,有一个非常简单的方法。
您将 Visual Studio 选项(工具/选项/文本编辑器)设置为使用空格而不是制表符,然后打开源文件和 Ctrl-E、D(编辑/高级/格式文档),它将为您全部转换!

Yay for automation!

是的,自动化!

回答by mcandre

I don't think there is an easy answer to this problem. I use Xcode and Visual Studio, and both have really annoying indentation. Maybe there's an option to disable autoindentation altogether.

我认为这个问题没有简单的答案。我使用 Xcode 和 Visual Studio,它们都有令人讨厌的缩进。也许有一个选项可以完全禁用自动缩进。