When I save file, VSCode auto cleans the not used code, How to Disable it? I want to make VSCode not to delete any line of my code.
Go to Visual Studio Code's settings page in JSON format then remove the line
"source.fixAll": true,
this line you will find inside of this object
"editor.codeActionsOnSave": {
},
After finding and testing, it can be configured at Workspace Settings > Go configurartion, override "go.formatOnSave": false, on the right side, disable formatting then the code will not be auto cleaned.
EDIT: Later then I meet this issue .
Related
I am a new Flutter learner, and this is kinda annoy me, I think the "Problems" tab under is fully understand, I don't want to see warning next to my code. Is there a way I can disable or hide it? Thank you.
Hey, In visual studio code you can do minute changes.
Step1:
Press ctrl+shift+p , a command pallet will open
Step2:
Type settings.json and click on Open Settings (JSON)
a file will open
step3:
Add this lines in that
"editor.codeActionsOnSave": {
"source.fixAll": true
}
**After this whenever you save, const will be added automatically.
Note: Sometimes you might get error because after saving some widgets are prefixed with const but, sometimes when your values in widget get dynamic, there will be a error, so be careful.
disable this line or add source.fixAll to config.json
Perhaps you are using some vscode plugin like https://marketplace.visualstudio.com/items?itemName=usernamehw.errorlens to show code diagnostics.
Though that feature seems very useful to me incase you find that annoying you may disable it by going through your list of extensions.
I just installed a beautify extension for vs code
I want to have my code beautified whenever I save a file, but can't figure out how to configure it that way.
It says
Beautify on save will be enabled when "editor.formatOnSave" is true.
But i have no idea where to put it exactly as I cannot find the default option in any of the files.
I'm trying to switch to VS code and figure things out.
For Windows click on 'File' -> Preferences -> Settings. Then search for editor.formatOnSave, and put "true" instead of "false"
For Mac click on 'Code' (top left of screen, to the left of 'File', 'Edit', and 'View') -> Preferences -> Settings -> enter the term 'editor.formatOnSave' in the search settings box at the top of the page. Click on the tick to mark it as true.
Go to file--> preferences --> settings
In search type formatter and in default formatter select : prettier code formatter as shown in below screenshot.
I visited this question because my beautify was not working in VS code
And Adding the above mentioned setting fixed my issue but if you want your beautify to solve linting issue as well then you gonna have to added the below setting along with the above like this : (Hope this helps anyone)
{
"editor.formatOnSave": true,
"tslint.autoFixOnSave": true
}
My setup for Javascript relies on ESlint and Prettifier.
I got the autoformat/autofix configuring:
"editor.codeActionsOnSaveTimeout": 2000,
"editor.codeActionsOnSave": {
"source.fixAll": true
}
In addition to the other answers, it may be that you have to override or replace your defaultFormatter settings in your settings.json file if you use other formatters.
When I installed Prettier, for example, it installed as the default formatter for several different languages, including HTML, which is broken for Django HTML templates.
Open settings.json file (SO guide if you get stuck
In my case, prettier had installed as default as follows, but you might have another formatter instead:
"[html]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
If you remove esbenp.prettier-vscode and start typing a few characters, VScode will highlight in red you have entered an invalid formatter and suggest valid values. Once you have installed Beautify, you can replace this entry with: HookyQR.beautify
And make sure to follow the other answers on this post.
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
VSCODE seems to be inserting spaces everywhere in my html code. I checked the settings and it's the following which is causing it: "editor.formatOnSave": true
Example:
How do I configure this to stop inserting spaces?
I have the following set :
"editor.formatOnSave": false,
"editor.insertSpaces": false
Now it is not inserting spaces. Hope it helps
Mine was caused by an extension JS/ CSS formatter, after i uninstalled and restart vscode works great.
After spending hours wondering why my django static links are broken smh
When saving, Visual Studio inserted a lot of spaces. This happened after an update of Visual Studio. This problem was because of an extension called Bracket Pair Colorizer. What I did was, uninstall and reinstall, and that solved the problem. I suggest to check all your extensions. It could be one of them.
I disabled the option of HTML formatting and no more space when saving files.
Settings > Extensions > HTML > Format: Enable
Enable/disable default HTML formatter.
What was the case with me is that I had the option Editor: Format on save mode to be set to file, this in combination with format on save would mean VS Code will try to format the entire file, resulting in spaces as defined in the formatter.
Change this to be modifictions, and VS Code will only save the lines you have made changes in.