No Space Please, Only Tabs for Indentation

来源:互联网 发布:unity3d 地形材质 编辑:程序博客网 时间:2024/06/05 21:16

Generally, most of code editors provide two options for indentation: space and tab. And I don't quite understand under what condition one should use spaces for indentation purpose instead of tabs; to me, that just makes your code less readable, nothing else.



Visual Studio:

You might need to visualize the space symbols before you can do anything to them:



To make VS apply tabs for indent automatically when you press 'Enter' key, you need to go Tools->Options:



In the dialog brought up, select Text Editor->C#->Tabs, and there you go. You can also specify other configuration of how the text editor perform the indentation, like 'Tab size', which indicates how many spaces' width should a tab occupy.



But what about the spaces that left behind by your stupid predecessor? Most of the text editors coming with IDEs provide a tool to convert indent from space to tab and vice versa, however, you need to highlight the lines before proceeding:



WebStorm:


Go to File->Settings: Expand 'Code Style', Select the language, tick 'Use tab character'





To convert indents:



To view the space symbols: go to View->Active Editor->Show Whitespaces


Notepad++:




SubLime 2


This editor has a wonderful function, which is to convert all the leading spaces in the opening file as indent to tabs:



NetBeans 8.0


Tab Setting:



Install themes:










0 0
原创粉丝点击