When collaborating with different developers, it is important to agree on a specific tab/space size to ease out the Pull Request/Merge Request process. For example:
Developer A is using 4 Spaces
Developer B is using 4 Tabs
Maintainer A is using 4 Spaces, same with Developer A
Whenever Maintainer C makes a change to a file which Developer A has formatted before, the merge process will go smoothly. The maintainer will only see what the changes are made.
However, when Developer B makes a change on any file which Maintainer A or Developer A has formatted before, the review process will contain all of that format changes and review process will be tremendously difficult for the reviewer. Now, Maintainer A will be seeing the entire file as changed due to indentation difference and the real changes might be overlooked.
Therefore, it is important to agree on a specific tab/space size before collaborating on any project.
Since Smartface Cloud IDE is based on Theia, you can install Prettier or different formatting extension to accomplish this task. However, using extensions might slow the development process on larger projects, therefore it might be a good idea to existing settings of Smartface Cloud IDE.
On Smartface Cloud IDE, open up the preferences:
If this box is checked, your codes will be in spaces. If not, they will be indented by tabs.
Whether you use tabs or spaces, with this configuration you can change the size.
Just like in any other code editor, when you press tab, the number of spaces will be indented if you set the size.
When you are pasting code from somewhere, or bulk editing something, you may want Smartface Cloud IDE to automatically format your code when you save or paste.
This will help your development to be easier.
You might not fond of formatting the file automatically or there might be times you want to overview your code formatted before saving.
The process is fairly similar with Visual Studio Code.
For mac: press
For Windows or GNU/Linux based systems, press
format and you will see the selections. Navigate and select
Format Document to format the current file you are in.
This will format your document based on the configuration you made previously.
Your project might have different file types due to various reasons, therefore you may want something like this:
2 Spaces for Typescript files
4 Tabs for JSON files
To accomplish that, you need to manually specify which file types will be configured on preferences JSON view.
Open preferences and click the JSON symbol as shown on the image:
Default configurations or your customized configurations will be shown line by line.
You can specify depending on the need of the project. For the example above, the configuration should look like this:
Notice that global formatting configuration is also there. File specific configurations will always override global formatting configurations.
cmd+space for Mac and
ctrl+space for GNU/Linux or Windows) with
"[ prefix to see other supported filesystems which you can specify rules to.