Reputation: 306
I am having trouble finding a setting for new line spaces in VS code. Currently, I have it set up to a tab is the size of 8 spaces (after detecting indentation from content). This is because a principal software engineer edits in a different program, and set tabs to be 8 spaces, but code inside brackets were only indented 4 spaces.
Is there a way to set new lines following a bracket opening to tab only 4 spaces, but keep the rest of my tabs set to 8 spaces?
I've tried resetting tabs to only 4 spaces, but that changes the document as a whole and the indentation is off.
For example, when tabs are set to 8 (after detecting indentation from content), this is what it looks like (I added a comment to show where hitting a new line brings the cursor to):
if ((access(LOGFILE, F_OK)) != -1)
{
if(remove(LOGFILE) == -1) // Remove the older file
{
//this is where the newline starts
printf("Unable to delete the older log file.\n");
return ERROR;
}
}
Whereas, when I set tabs to 4, this is what it looks like (if statement indentation is bad):
if ((access(LOGFILE, F_OK)) != -1)
{
if(remove(LOGFILE) == -1) // Remove the older file
{
//this is where the newline starts
printf("Unable to delete the older log file.\n");
return ERROR;
}
}
Is there a way to change it so I can use the 8 tab format (first example), but when a new line is created after an if statement, it'll only add 4 spaces? Normally. I would just reformat the whole file with a formatter and select those options, but that would make looking at changes when pushing to git nearly impossible, plus the other software engineer still uses the tab 8, spaces 4 system to edit.
Any help is appreciated!
Upvotes: 1
Views: 4256
Reputation: 51
Indentation is same in whole file, you cant use two saperate indentation at once simple solution will be: set your tabs to 4 spaces and use tabs 1 and 2 times whenever needed.
For reference: Indentation | VS Code Docs
Upvotes: 2