When I write C# code in VS Code and start typing some word and IntelliSense appears and focus on some suggestion I can press dot or space and this word appears in code.
But in python I strictly have to press Enter only if I want to get suggested word. Is it possible to make IntelliSense in Python behave like it behaves in C#?
Try changing the following lines to your settings.json file
"editor.acceptSuggestionOnCommitCharacter": true,
"editor.acceptSuggestionOnEnter": "on",
"editor.quickSuggestions": {
"other": true,
"comments": true,
"strings": true
}
In addition to #DreamyPlayer's answer, add the following line to settings.json (or rewrite it, if key editor.inlineSuggest.enabled exists):
"editor.inlineSuggest.enabled": true
I'm editing someone else's code and I only want to change 1 line of a 9000 line file. But every time I save, VS Code formats the entire file and removes any trailing white space. This is a no-no because when I push this up, the reviewer will have no idea which line to look at.
I've tried disabling prettier, adding all files to .prettierignore, going into VS Code settings and disabling any suggestions of a formatter or white space trimming, turning off formatOnSave.
Here is my .vscode/settings.json
{
"prettier.disableLanguages": [
"js",
"json",
"javascript"
],
"javascript.format.enable": false,
"typescript.format.enable": false,
"json.format.enable": false,
"html.format.enable": false,
"emmet.showAbbreviationSuggestions": false,
"css.validate": false,
"editor.defaultFormatter": null,
"editor.formatOnSave": false,
"[javascript]": {
"editor.formatOnSave": false,
"editor.defaultFormatter": null
},
"editor.trimAutoWhitespace": false,
"diffEditor.ignoreTrimWhitespace": false,
"files.trimTrailingWhitespace": false,
"files.trimFinalNewlines": false,
"eslint.format.enable": false,
"files.autoSave": "off",
}
The only thing that seems to work is if I do CTRL + SHIFT + P, then SAVE WITHOUT FORMATTING. But what setting can I have so I can just do that with normal saving?
Did you try adding
"editor.formatOnSave": false
in your user settings rather than in your project settings?
Had the same problem, just bind 'cmd + s' to saving without formatting.
press cmd+shift+p then search for save without formatting and click on the configure icon, then bind it with 'cmd + s', problem gone :)
In the case it is ESLint, and not Prettier, the solution is:
Open Preferences: Open Settings (JSON) and configure:
"editor.formatOnSave": false,
"editor.codeActionsOnSave": {
"source.fixAll": false,
"source.fixAll.eslint": false
}
I don't have Prettier but the solution may be similar.
In my case, I uninstalled prettier and was using html-css-js code formatter. I had already unchecked format on save, and had tried many other methods. I finally changed a setting in formatter.json (settings of html-css-js formatter) and then it worked.
Steps:
ctrl + shift + P
Formatter Config
If "onSave": true, change true to false
Save the formatter.json and reload window.
This worked for me. I can use auto-save after this as well.
I came across this problem a while back. I disabled the formatOnSave option in settings.
Goto File > Preferences > Settings or Ctrl + ,.
In User tab choose Text editor and navigate
to Formatting, disable the formatOnSave option.
YW!
Perhaps this plugin called Formatting Toggle by tombonnike can help you.
It disables the autosave with a toggle.
From its description:
A VS Code extension that allows you to toggle the formatter (Prettier, Beautify, …) ON and OFF with a simple click.
In my case I had two default code formatters that had conflicting settings, "prettier" was set not to format on save but JS-CSS-HTML Formatter was still set as my default formatter for some file types. I suggest using only one formatter and removing any unused / conflicting ones from your extensions list.
The way I used was to:
Open a file type ( one that's giving you formatting on save issues. )
Click on the file type and select "Configure 'yourFiletype' language based settings.. from the dropdown.
Delete the line that sets your default formatter: ex) "editor.defaultFormatter": "lonefy.vscode-JS-CSS-HTML-formatter"
Then go back to your file and try formatting normally, ( my hotkey is: alt + shift+ f ), it should prompt you to select your default formatter.
This should help minimize conflicting formatters issues.
I've just stumbled across this question while experiencing the exact same problem. The way I solved it, was just to switch the language of the document to plain text (you can do so by clicking on the language in the bottom navigation bar). If you then hit "save", no reformatting happens.
Disadvantage: You get no syntax highlighting. But if you just want to fix a typo or something and don't want to mess with the settings or install an extension, it's probably an ok workaround.
Save without Formatting
The ideal solution to this would just be to use the "Save without Formatting" command.
This can be executed by either:
Selecting it in the command palette: CTRL + SHIFT + P
Doing the keyboard shortcut: CTRL + K, S
This lets you save files, bypassing any formatters that may run automatically.
Format on Save
You might want to disable auto-formatting entirely. You might just not like it, or because it can be annoying when paired with files.autoSave which saves automatically, and therefore formats automatically too.
First check your global settings and see if you have editor.formatOnSave enabled. If so, then disable it.
You can navigate to your settings by either:
Navigating the menu bar: File → Preferences → Settings
Doing the keyboard shortcut: CTRL + ,
Then search for editor.formatOnSave and disable it.
If it's still auto-formatting, then it might be enabled in workspace settings. Check if the root of the workspace has a file at .vscode/settings.json, and if so, if it has editor.formatOnSave. If it does, then either disable it there or just delete the file to stop it from overriding your global settings.
Other Extensions
Check if any other extensions are performing code actions on save. Other answers here cover this topic a bit, but in general, you can just navigate through your setting and search terms like "save" or "format".
All UI navigation and keyboard shortcuts are taken from the Linux installation, they may vary on other platforms.
Go to C:\Users[user]\AppData\Roaming\Code\User
and change the editor.formatOnSave option to false.
I just got the same problem and while trying these solutions, I realized that when you click ctrl + shift + P, and type "Save without formatting", the option will have a settings icon on the right corner, click there to configure keybinding, you can put any keybinding you want there, for example ctrl + k, which I put. It worked instantly and it was very easy, so you can have the best of both worlds.
Thanks to Guillermo's answer.
In VScode Goto File -> Preferences -> Settings -> (User tab) Text Editor -> Formatting -> Here uncheck the Format On Save
So when I type in an emmet abbreviation like div.result which should then expand to <div className='result'></div>. However, with Intellisense, VS Code detects that I have a filename called MovieResults, and suggests it.
I hit esc because then otherwise, my emmet abbreviation turns into <div className='MovieResult'></div>.
The suggestion goes away, but from there, I don't know of any other way to expand the abbreviation, other than setting "emmet.triggerExpansionOnTab": true.
Any ideas on a solution to this? It's just bugging me that I'm trying to name the className as results, but Emmet isn't offering me an autocompletion for it.
Here are some images of what I'm talking about:
In my case I had changed to:
"emmet.showExpandedAbbreviation": "inMarkupAndStylesheetFilesOnly",
changing back to the default fixed the issue:
"emmet.showExpandedAbbreviation": "always"
Also this will help:
"emmet.showSuggestionsAsSnippets": true,
"editor.snippetSuggestions": "top",
According to the official document, https://code.visualstudio.com/docs/languages/markdown
Snippets for Markdown
There are several built-in Markdown snippets included in VS Code -
press Ctrl+Space (Trigger Suggest) and you get a context specific list
of suggestions.
Does there any way, trigger snippet automatically when I type word, because it's troublesome, press Ctrl+Space
Try setting:
"[markdown]": {
"editor.quickSuggestions": {
"other": true,
"comments": false,
"strings": true
},
},
This enables IntelliSense automatically when you start typing. By default, this will show snippets and word based suggestions (suggestions based on words in the current document). To disable word based suggestions, set:
"[markdown]": {
"editor.quickSuggestions": true,
"editor.wordBasedSuggestions": false
}
You can also set:
"editor.snippetSuggestions": "top"
If you always want snippets to show before word base suggestions
There is an inconsistency in VS Code and it is a known issue. Markdown snippets do not get auto-completion. Probably it will be fixed in next release.
Yes this is an inconsistency. Full extensions get auto (7x24) completion by default (e.g. latex, cake), some built-in extensions like Markdown do not.
https://github.com/Microsoft/vscode/issues/1617#issuecomment-166999086
Visual Studio Code Version 1.10 adds the ability to specify languages settings on a per language basis (*1). You put something like this in your settings.json file:
"[javascript]": {
"editor.fontSize": 100,
}
I'd like to do something more specific. I'd like to apply different rules to files that match *.min.js.
How would I do that?
I've actually got something that works, but it's a bit hacky, so I thought I'd ask.
*1) In case you want to know which ones: Use autocomplete after typing in "[]":, or see languageIds array in this file.
I'm aware beautify skips formatting min files by default. But just using "editor.formatOnSave": true, this doesn't seem to happen. Also, other non-formatting stuff like wordwrap is nice.
Here's my current solution:
"files.associations": {
"*.min.js": "javascriptreact"
},
// Hijack javascriptreact to create custom settings for min.js files
"[javascriptreact]": {
"editor.formatOnSave": false,
"editor.wordWrap": "on"
}
I'm using the fact that vscode happens to have a second type of javascript, one that isn't used my my project. Not ideal, but it seems to work.