VSCode: focus on file after clicking on it it in file explorer - visual-studio-code

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?

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"

VS Code automatically move cursor to editor on open from tree view

What I'm looking for seems to be such a basic thing that I'd expect it to be managed by some setting, but I can't find it.
When I click on a file name in the file explorer, the file opens correctly, but the cursor focus remains in the file explorer. I'd like it to automatically put the cursor in the file editor.

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.

Eclipse - Can't View or Open Java files in Package Explorer to Editor

I clicked something or accidentally drug a file that was open in the editor and now it is no longer displayed.
If I double click on the file in Package Explorer it doesn't show in the editor like it used to. I have looked all over and can't figure out how to get this file back in the editor.
I thought clicking File - Open File would do it but that displays an open file dialog.
Another way to simulate this is to put the cursor in the editor for an open file and select File - Close. This closes the file but then if you double click on the file in the Package Explorer it doesn't open it in the editor anymore. How do I get these files to display in the editor again?
I also tried right clicking on the file and selecting "Open". This does not display in editor either.
I also tried right clicking and selecting "Open With Java Editor". This does not work either.
If I clicke "File" and then the name of the file in the MRU list . This does not work either.
Also, double clicking a file in Package Explorer fails to open any file. The file shows in the File MRU list but does not display in editor. Can not figure this out.
Also, if I select "Back to" or "Forward to" arrows on toolbar, it tracks the file in the Package Explorer by highlighting it but the file does not display in an editor like it used to.
Also, I have tried "File Open" browsing to the physical location and selecting it but that does not display in the editor either.
I had to open a new window (Window - New Window) and then Reset Perspective (Window - Reset Perspective) to get the editor back. Not sure why but I lost some of my perspective settings doing this.
In Package Explorer, instead of double-clicking on the file, try to right-click it and you should get several "Open with..." options; choose the one that matches the editor in which you want the file to open.
Your choice will also be saved as the default, so the next times you can just double-click and it will open in that same editor.
If you are customizing the perspective, then saving perspective could be a safer option to avoid such glitches.
PFB the link on how to save a perspective:
http://help.eclipse.org/mars/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2FgettingStarted%2Fqs-43e.htm

In RubyMine, how to preview a file's contents by selecting it like in Sublime Text?

I'm new to RubyMine 7 on Mac.
I used to use Sublime Text 3 and I love RubyMine so far except its lack of file previewing.
In Sublime Text, when clicking a file in the sidebar (file explorer), the selected file content shows in an editor tab for temporary viewing.
If I select another file, then the same tab changes to the content of the newly selected file.
I've been searching for this preference setting in RubyMine, or in a plugin, but I've had no luck.
A similar feature is "Autoscroll to source" but this feature opens files rather than previewing them.
If anyone knows how to do Sublime Text-like file content previewing in RubyMine, I'd appreciate it.
RubyMine doesn't have a feature exactly like Sublime Text file previewing.
The Quick Definition action can sometimes meet the same need. When invoked on a file, it opens a popup with the file's contents. You can invoke it on a file in the Project or Find pane and probably other panes, dialogs, popups, etc. that list files. (You can also invoke it in an editor on an identifier such as a class, module, or variable; it will show the code that defines the identifier.) Invoke Quick Definition with ⌥-space or ⌘Y in the Mac OS X 10.5+ keymap; use ^⇧I on Windows or check Preferences → Keymap for other keymaps, or use ⇧⌘A qd ⏎. Hit Escape or click outside the popup to close it.
When you invoke Quick Definition on a file in the Project pane and navigate to other files in that pane (with down and up arrows to move between files, and right and left arrows or Enter to open and close directories), the Quick Definition popup will stay open and update to the currently selected file, which is relatively close to Sublime Text file previewing. You can also hit Enter to open a file, F4 to open a file and move focus to the editor, edit the file, ⌘1 to jump back to the Project pane, etc., all with the Quick Definition popup still open, until you choose to close it.
If that isn't close enough, there are two feature requests for Sublime Text-like file previewing in JetBrains IDEs which you can vote for:
Preview currently selected file in project window
File Preview features from Sublime