I have some dart code I am looking at in vscode.
The dart code uses 4 space indentation (literal 4 space, opposed to tabs).
When I view the code in vscode, it is putting line guides every two spaces. This doesn't make any sense since the indentation only occurs every 4 spaces. So it is essentially showing line guides to no where.
Observe the following screenshot
How can I fix this???
Go to Files > preferences > settings > select:Editor-Tab size You can change tab-size there.
Note: If you are using Eslint or Prettier make sure your editor settings are not overriding
The problem is that editor.tabsize setting is being overridden by language specific settings.
To fix I put the following in my user settings.json file...
"[dart]": {
"editor.tabSize": 4,
"editor.insertSpaces": true,
"editor.detectIndentation": false
},
Related
When I updated Visual Studio Code, I am getting this annoying red indicator/highlighting before every line of code. Before the update, didn't have this issue. Does anyone know what is this and how to get rid of it?
I tried resetting and changing the theme but it didn't work.
I think this extension is causing your problem:
https://marketplace.visualstudio.com/items?itemName=oderwat.indent-rainbow
Try to disable/uninstall the "Indent-Rainbow" extension if it is installed.
For the "Trailing Spaces" extension, you can disable the highlighting option by adding this line to the settings.json file.
{
"trailing-spaces.highlightCurrentLine": false
}
You can find more settings here:
https://marketplace.visualstudio.com/items?itemName=shardulm94.trailing-spaces
I had the same problem and I thought it must be some extension causing this and so I took a deeper look at all my extensions.
In my case there was an extension called 'trailing spaces' which was causing this.
the red highlighting disappeared as soon as I uninstalled it.
Try doing the same and if it doesn't work try to take a look at all of your extensions. (An easier way to do that would be to go over the extensions tab on the left navigation bar in settings menu).
On the bottom bar, to the right, just beside the "Ln XX and Col XX" you can choose "Select Indentation" to indent using spaces or tabs. Change that configuration or choose "detect indentation from content" and will solve the red background.
I just had to change the tab size from 4 to 2 (as configured within my eslint setup)
I kept the Indent Rainbow extension, but added this to my settings.json to disable the red highlights:
"indentRainbow.ignoreErrorLanguages": [
"markdown",
"python"
For my case it was an extension called Bracket Pair Colorizer
I'm trying to configure Visual Studio Code to treat tab characters in files as being 8 spaces but have indentation (when I hit tab on the keyboard) as being 4 spaces. Is this at all possible?
I can achieve this in eclipse with the code style formatter but can't achieve the same thing in VS Code.
(I've submitted an issue to the VS Code repository on git hub now https://github.com/Microsoft/vscode/issues/42643)
You need to modify your user settings (or workspace settings) in VS Code. By default, it is set a tab as 4 spaces.
You can modify the setting "editor.tabSize": 4, and set that to 8.
However, also be aware that "editor.detectIndentation": true, is set to try by default and this causes VS Code to detect the indication size of the file you open. So if the file itself has spacing set to say 4 or even 2, then VS Code will auto set spaces to that value while that file is open...or until you convert indentation.
You can convert indentation via the command palette and that should update the spacing to your desired setting.
As far as I've seen, No.
It appears that VS code still can't separate the two concepts of tab size and indentation distance. Some suggestions, ideas and hopeful soulmates of ours can be found in this issue on github: https://github.com/Microsoft/vscode/issues/5394#issuecomment-215414643
I agree with the comments in that issue in that separating the tab size from the indentation distance is a nice feature that solves several problems. The only thing needed is for someone to actually do the work to implement that in vs code.
Or, a less intrusive route, I have actually been thinking about creating an extension to override the indentation action in some way and use a custom settings variable for the indentation distance there... but I have yet to learn enough about the internals of VS code to determine if that's even possible for an extension to do.
I have the following settings in VS code to disable word wrap
"editor.wordWrap": "off",
"editor.wordWrapColumn": -1
Word wrap is still not turned off. This makes VS Code really unfriendly to use on my laptop with a small screen.
Is there some additional setting I can use?
I am on 1.17.1.
Are you using markdown? vscode changes some default settings:
"[markdown]": {
"editor.wordWrap": "off"
}
On version 1.17.1 try changing default settings (not overriding with user settings) to:
"editor.wordWrap": "off",
"editor.wordWrapColumn": 80,
That works for me. And you can also edit the user settings (via Code or directly editing settings.json file on AppData\Roaming\Code\User (at my computer) by just adding the wordWrap line.
After changing settings always close and reopen both VS Code and the file (as it saves it opened).
If you are dealing with a file that has very long lines, this could be the issue you are facing.
https://github.com/microsoft/vscode/issues/21124
It seems it is made that way by design to prevent slow load times. It can be manually overridden with ALT + Z shortcut while the file is opened. After that, it reverts to the old setting and you have to do it again.
My problem is not present while editing a file, like here: Spaces to tabs in Visual Studio Code
VSC converts all tabs to spaces when I save the file. How could I stop that stupid behavior?
This are my actual user settings:
{
"editor.insertSpaces": false,
"editor.detectIndentation": false
}
Further informations:
"editor.formatOnSave": false
Wish I understood more about what's happening here, but in my case, what finally worked (for now) was unchecking "Editor: Insert Spaces" in my user prefs. Without this, disabling Save on Format didn't seem to help. ¯\_(ツ)_/¯
I had an extension which overrides the default behaviour:
https://marketplace.visualstudio.com/items?itemName=lonefy.vscode-JS-CSS-HTML-formatter
I've noticed that in my project, my project files don't adhere to the settings. EG tab == 4 spaces. Tabs are only adding 2 spaces. The settings file does it properly. It uses 4 spaces with I hit tab. Do I need to add something to include the project files? I've tried adding this to my user settings. I also added this to the workspace settings but it still didn't seem to work.
"editor.insertSpaces": false,
"editor.tabSize": 4,
and tried using true as well. It just doesn't do it. The project files seem to be ignored. Is there some place I can fix this?
You need to also set "editor.detectIndentation": false,, otherwise the program auto-detects the indentation based on the open file. Documentation has default file that should help with any other settings.