Automatically save files in eclipse when closing tab - eclipse

In Eclipse (CDT) when I close a modified file's tab in the code editor, I'm prompted with whether or not I want to save the file. Unlike when I run the project, I'm not given an option to autosave the file when closing a tab in the prompt that comes up. I haven't been able to find one yet, but is there any setting in the Eclipse Preferences that disable these prompts and automatically save modified files when I close their tabs (not every x time)?

You can use auto save feature in eclipse neon. See this answer also look at other answers to this question Eclipse save automatically

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.

In Eclipse, is there a short cut key to open a editor in a New Window?

I am editing a .java file in eclipse, is there a short cut key to launch/open the current .java file I am editing into a new window to make use of my multiple displays?
I am using Eclipse 3.x
There is no shortcut key in Eclipse to reopen a file in a new window, but I'm unclear on how that would work anyway. Maybe I'm missing something, but how would Eclipse know which display to use, where to position the new window on the display, and what dimensions to use for the new window? And even if it did know how to do all that, it's not improbable that you would still want to adjust the size and positioning of the new window.
Besides, there already is a better alternative to a shortcut key: just position the mouse cursor over the tab of the open file, drag it to wherever you want on any of your displays, and optionally resize that new window as desired. The change will persist over restarts of Eclipse.
(I verified this on the latest release of Eclipse, Oxygen.2 Release 4.7.2, but I don't know when that drag and drop functionality was first implemented.)

How to disable file auto-focus in VSCode Explorer panel when file is opened by navigating tabs?

I wonder if there is a setting or a feature request should be submitted for the following:
Currently, if you pick a file from the project explorer, it goes into its own tab. If you have several tabs opened, as you focus any one of them, the file itself also gets focused in the project explorer.
For larger projects where you navigate through a lot of files in the project and open files here and there this could actually be a distraction - for some people it would be better not to focus the current file in the project explorer and not lose sight of the last file you actually opened and its neighbour-files.
Another scenario is when you debug a node.js app and need to debug repeatedly with F11 - a lot of times you could find yourself in some ultra-deep node_modules folder that takes over the whole project explorer - and you need to close this manually later to bring the project explorer to order.
To answer the first part, if you add this to your workspace or user settings, vscode will no longer automatically show the currently active file in the file explorer.
"explorer.autoReveal": false
To answer the second part, if you like to have the current file focused but you don't like having the explorer section expanded all over the place, there is a command that can help you. If you put something like this in your keybindings, then whenever you feel the explorer has become unruly you can use the keyboard command. It is also available in the command palette ("Files: Collapse folders in explorer") and there is an icon in the file explorer that looks like this: [-]
{
"key": "ctrl+shift+t",
"command": "workbench.files.action.collapseExplorerFolders",
"when": ""
}
I have also created an extension that can automate this.
You can use a param:
"explorer.autoReveal": "focusNoScroll"
Focus to file will not disabled, but it will work without scroll (that's clear from the param value). It is usefull sometimes.

How do I stop VSCode from the Side Bar moving to the folder that the current file is in?

In Visual Studio Code, whenever I close a file, the next open file becomes active in the editor and the Side Bar moves to that file's location in the folder structure. This is usually not the behavior I want. I often want to open another file in the same location as the one I just closed, but now my Side Bar has shifted around to what could be a totally different place in a large project.
I like the behavior of the main Visual Studio product where the Solution does not automatically shift. Instead, if I want to see where in the solution a file is, I can use a keyboard shortcut to move there ("Find File in Solution"), instead of automatically moving there every time the active file changes.
Is there any way to change/disable this functionality in VSCode?
The is an option explorer.autoReveal in settings (either user or workspace) which controls if the explorer should automatically reveal files when opening them.
Open VS User Settings (Preferences > User Settings). This will open two side-by-side documents.
Add a new "explorer.autoReveal": false setting to the User Settings document on the right if it's not already there. This is so you aren't editing the Default Setting directly, but instead adding to it.
Save the User Settings file.
in Version: 1.42.1
Open VS User Settings (Preferences > User Settings).
Search for "explorer auto reveal" without quotes.
Now uncheck the checkbox.
There is a new setting in v1.46 that will select the files in the explorer but not scroll to reveal them:
We have introduced a new value focusNoScroll to the
explorer.autoReveal setting. For this value Explorer will
automatically select files when opening them but will not reveal them.
from v1.46 release notes.
So that setting will highlight the active editor in the explorer but not scroll to it.

Undo operation in a reopened tab in Eclipse

In XCode actually there is no closing and openning tabs and you can undo whenever you can even if you open another file and go back.
In Eclipse when you close a tab and then later re-open it you cannot undo of course.
Is there a quick way to do this?
You can't undo actions if you have closed the tab (which seems logic: if it's closed, it's not in use). A solution is to use the local history, which can be found when you:
Right-click the file in a navigation view and select Team > Show Local History.
you will see a different version of your file for each save you've made. From there you can compare, or restore it from a certain date.
note: You can change local history properties in:
Window ->Preferences > General > Workspace > Local History
(e.g.: if you want Eclipse to keep files longer or to keep more files)