How to turn off sound warning vscode does on editor close for unsaved files? - visual-studio-code

I use vscode for pairing and I find the warning of "unsaved file" very annoying, is there a way to remove it?
GIVEN
An unsaved file in VSCode on Ubuntu
WHEN
The user clicks on close the editor (just the tab, no VSCode itself)
THEN
A popup with the message «Do you want to save the changes you made to » appears and a noisy sound alert rings
popup
DESIRED BEHAVIOUR
The sound alert does not ring (optionally: the popup doesn't appear either)

Related

How to get editors restored when reopening a closed VS Code window?

I am using VSCode on my Mac (Latest version) and when I hit the "Red X" on the top left of VSCode it closes my entire workspace and open editors. I want it to just close the window out of my view but keep everything open when I re-open the app (it is still running as it still has the white dot below).. I am getting the welcome page everytime I just "close window" and re-open.
Now if I were to two click and hit Quit, then yes, I'd expect my workspace and editors to all close and get the startup menu on re-opening.
I have tried searching in the settings and cannot find anything.
GUI Red X - VSCODE
Example. When playing music on iTunes and press the "RedX" on the GUI music keeps playing and everything opens as it was when it was closed. Thatis what I am trying to acheive on VSCode. Keep my "sandbox" and open files as is when pressing it..
To VS Code, I'm pretty sure that red x button and quit are the same thing (although it may be possible for it to treat them differently). Ie. I'm not aware of a way that you can get different behaviour for the red x button and the application quit action.
As for choosing whether the previous workspace should be reopened automatically, you can use the window.restoreWindows setting.
Controls how windows are being reopened after starting for the first time. This setting has no effect when the application is already running.
The values to choose from and their descriptions at the time of this writing are:
value
description
"all"(default value)
Reopen all windows unless a folder, workspace or file is opened (e.g. from the command line).
"folders"
Reopen all windows that had folders or workspaces opened unless a folder, workspace or file is opened (e.g. from the command line).
"none"
Never reopen a window. Unless a folder or workspace is opened (e.g. from the command line), an empty window will appear.
"one"
Reopen the last active window unless a folder, workspace or file is opened (e.g. from the command line).
"preserve"
Always reopen all windows. If a folder or workspace is opened (e.g. from the command line) it opens as a new window unless it was opened before. If files are opened they will open in one of the restored windows.
If you want open editors to be remembered and the previous workspace to be reopened automatically when you reopen VS Code,
You may also want to set something for the workbench.startupEditor setting, such as:
"workbench.startupEditor": "welcomePage", // or "none" or "newUntitledFile"
Also, loosely related is the "workbench.editor.restoreViewState setting, but the default value is true, so you only need to touch it if you don't want view state info like scroll position to be resotred on reopening closed editors.

How to re-enable the "vscode is corrupted" message

I had this message that said "Vscode is corrupted" on the bottom right corner of vscode, and I clicked on the settings icon on the message and checked "Don't show again" (the reason why my installation is corrupted doesn't matter, that's not at all the context of this question)
I want to revert that => I want to see that message again on every launch, just like it used to
So how to revert that action without resetting vscode? I checked in vscode settings but didn't find anything related.

See unsaved changes in vscode

Sometimes when closing vscode, or a tab therein, I get a dialogue asking "Do you want to save the changes you made to filename?" However, the unsaved edits are actually from a previous session that was closed without such a query, probably when turning off the computer, so I can't remember if it was meaningful edits, or maybe just an accidental key-press, like a shortcut gone wrong; and doing undo to revisit the last edits doesn't work either.
My question: How can I see the diff between the saved version of a file, and the version in the editor window? I think it would be nicest just to have a "show diff" option in the dialogue, but for now I'm also happy with a command line diff command.
I'm using ubuntu 20.04.
I'm using VSCode version 1.52.1 on MacOS and I had a similar problem that may not be the same problem, but I'm guessing it will work for you as well.
When you're in the Explorer view, in the upper left part of Explorer you have your "Open Editors." If that shows a dot to the left indicating that the buffer has changes in it, you can right click the file name and select "Compare with Saved." This will open another buffer to the side that will show you any unsaved changes.
To get rid of that window (it took me a bit to figure this out I'm sorry to say!), you can click the 'X' to the left of the extra buffer in "Open Editors."
Hope this works for you!
A few bright notes for the keyboard players out there:
The command you are asking about has a default shortcut. Unless you've applied a keyboard map extension, the Ctrl+Kd arpeggio opens the very same diff view between the active and saved versions of the current file. The default shortcut to close an editor tab (be it the diff or a file or anything at all) is Ctrl+W.
The command, like any command in VSCode, is also accessible via the Ctrl+Shift+P command dropdown (on Linux, F1 opens it too). Start typing e.g. compa sav (it saves your keyboard wear and tear to shorten words to a prefix which is unambiguous enough), and the list will shrink dynamically to just a few commands. Yours is File: Compare Active File with Saved. When it's close to the top enough, navigate the list of commands with the down arrow and execute it with Enter. As a bonus, you may click on the little gear to the right of the command currently highlighted in the list and redefine its shortcut, if you use it very often and prefer a chord shortcut to the default arpeggio one. Sorry, there does not seem to be a shortcut in lieu of the gear click. If there is, please let me know!
But if you really, really want to right-click on the filename in the Open Editors view of the Explorer sidebar, you can open that view directly with, you guessed it, a shortcut: Ctrl+Ke. And if you change your mind on a dime right at this moment, or realize that you in fact never had a mouse to do the right-click in the first place, use Shift+F10 to drop down the "right-click menu", properly called the context menu, which you navigate with arrows and execute with Enter (that's kinda a common theme, as you probably noticed). This works mostly anywhere the right-click does.
While in the Open Editors view, to switch to an editor file tab, move the selection to the desired file. Press Space to bring the file into view but stay in the Open Editors view, or Enter to bring the file into view and shift the keyboard focus to it. Pressing Ctrl+Shift+E brings focus back to the editor from any view in the Explorer sidebar. The same shortcut moves focus to the Explorer sidebar from the editor.
Happy ♬ k'boarding ♬!
ctrl+shift+P (or command+shift+P on mac) and fuzzy search for "compare changes with saved files"

How do I stop Visual Studio Code (VSCode) from linting new, unsaved files?

In Visual Studio Code (VSCode), I often want to temporarily store some text while coding. A quick way to do this is to hit Ctrl + N (to open a new file in a new tab) and then Ctrl + V (to paste the text). I can then go back to the new tab later on and retrieve the text. This is safer than using the clipboard, because I don't want to accidentally blow it away by copying something else.
However, the ESLint extension for VSCode will automatically detect that I have pasted some JavaScript code into a new file and will immediately start linting it, even though it is a brand new & unsaved file. This clutters up the "Problems" pane with spurious errors.
How do I prevent this from happening?
The solution is to click on the language icon in the bottom right hand corner, and switch it to Plain Text (plaintext).
This will obviously disable the linter, because it won't be a JavaScript/TypeScript file anymore.
It's also probably possible to make a VSCode hotkey that will do this in one keystroke, but I don't really do this pattern often enough to justify making a custom hotkey for it.
Search preferences for "Format on paste" or in settings.json enter:
"editor.formatOnPaste": true

VSCode: focus on file after clicking on it it in file explorer

I swear something has changed with VS code. You used to be able to click on a file in the file explorer, and it would automatically focus on the body of the file, so you can start typing immediately. Now, (1.36.1), when you click on a file in the file explorer, it stays focused on the file explorer, so if you start typing after clicking, it will start a search inside the explorer instead of the editor. This is extremely user hostile and I really want it disabled, it's totally throwing off my flow. How can I disable this?