I want to remove the indentation lines that are marked in red as they serve no purpose. I want to make the indentation of 1 tab = 4 spaces, but VSCode automatically made it as 1 tab = 2 spaces. How can I fix this?
I want to remove the indentation lines that are marked in red as they serve no purpose.
File->Preference->Settings and search for "renderIndentGuides".
uncheck Editor: Render Indent Guides
I want to make the indentation of 1 tab = 4 spaces, but VSCode automatically made it as 1 tab = 2 spaces.
Gotto
File->Prefrences->setting -> Detect Indentation -> Click editor:TabSize
Here you can update to 4
Related
So the standard setting seems to be 1 tab equals 2 spaces for indentation. I always change that to 4 spaces, you can see that here
. But that setting never seems to save. When I work with Visual Studio on the next day, its back to 2. May it be that the Prettier Extension is overwriting something?
I found the problem: The setting "Editor: Detect Indentation" has to be turned off. Also you can go to Prettier's Settings and set the Indentation to 4 Spaces too, so when autoformatting, the indentation of 4 instead of 2 spaces is kept.
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!
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
This is the formatting I want to achieve:
function x() {
$elementOfSomething
.find(".class")
.remove();
}
This is the formatting VSCode does by default:
function x() {
$elementOfSomething
.find(".class")
.remove();
}
The default indentation is 4 spaces. In the second sample, the third and fourth lines are indented by 4 spaces in relation to the previous line. In the first sample, they are indented by 8 spaces. So I want to the default indentation to be 4 spaces but the continuation indentation to be 8 spaces. In NetBeans, there is the setting "continuation indentation" for this. Is there a way to achive such indenation behaviour in VSCode (for JS and Java)?
In VS Code this setting is called "wrapping indent", and this setting is located within the Text Editor category of settings.
Sounds like you want to set your wrapping indent to the "deepIndent" option, which will relatively indent the wrapped line to the width of two tabs. For example, if your tab size setting is 4 spaces, a deepIndent will be 8 spaces.
By this I mean if some file was written with 4 spaces, can you simply highlight it all and click on something to turn it into 2 spaces. I'm not sure if in practice (parsing) this would make sense/could lead to broken code.
I currently have my editor.tabSize set to 2, and sometimes I open files written with 4 spaces and I want to be able to turn them into 2 spaces. I have at least figured out to turn off the auto-detect so that when I highlight sections of the code and hit shift-tab, then tab again it will turn the selected code from 4 spaces into 2 spaces.
Is there a feature like this or does it make sense that this wouldn't exist?
To change the current document from using 4 spaces to 2 spaces:
Click on Spaces: 4 in the status bar or run the Indent using Spaces command
Select 2 for the new tab size
Run for Format Document command to apply the new indentation to the entire document
Whenever I let vscode autoformat my code, it formats to 2 spaces instead of 4, even though apparently the default is 4 spaces, and I have not touched the settings.json
Editor.tabsize also shows 4.
In the bottom right hand corner, its shows spaces: 4, but after autoformatting, it shows spaces: 2, and will revert itself back to 2 no matter how many times I change it to 4.
Anyone know what's going on. This is happening with Ruby, if that matters.
Also, does anyone know of an alternate indenter/autoformatter for VScode?
I think that you might have a problem with "Auto Detect Indentation". You should try to turn it off and see if that helps.
// The number of spaces a tab is equal to. This setting is overriden based on the file contents when `editor.detectIndentation` is on.
"editor.tabSize": 4,
// When opening a file, `editor.tabSize` and `editor.insertSpaces` will be detected based on the file contents.
"editor.detectIndentation": false
For those who could not use above like me, Here is somewhat GUI guide.
Go to setting by pressing = > CTRL + , (suggested by comment) to open settings or via menue
File->Preferences->Settings
There you can find both (find tab size and detect indentation) in search box, like I have shown in following image (see the text 'lets play')
detect indentation => uncheck it (turn off)
tab size => Set it to 4
How to ? need to visualize? here it is,
Right click following image and open in new tab see it clearly
I solved this problem using https://editorconfig.org/
# EditorConfig is awesome: https://EditorConfig.org
# top-most EditorConfig file
root = true
[*]
indent_style = tab
indent_size = 4
end_of_line = crlf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
Make sure to also install the vs code extension!