"Go to file" with VSCode, instead of goToSymbol - visual-studio-code

I see this line in keybindings.json
{ "key": "shift+cmd+o", "command": "workbench.action.gotoSymbol" },
which you can see here:
However, I am trying to find the shortcut for "goToFile" - is there such a shortcut?
Currently, to find a file by name, I use "goToSymbol" and then I delete the ampersand and then type the filename and it works, but that's an extra step I'd like to avoid. See:
So my question is, does anyone know how to go directly to searching for a file by name, instead of using goToSymbol?

It's ctrl+p by default, workbench.action.quickOpen.

Related

How to hide options menu when cursor is inside single or double quotes in sublimetext

I am trying to use the autofilename plugin, but for some reason it replaces me or incorrectly corrects the file path, I think I know that it is because of the options that automatically appear as references when the cursor is inside single or double quotes by example:
As you can see, several options that do not exist such as directory or file names are shown, those names are mostly names that exist in class and id, among other things.
So how can it be avoided that only when the cursor is inside single or double quotes that these options do not appear.
As I mentioned I am trying to use the autofilename plugin but it automatically deletes or corrects me wrong data, I am using sublime text 4113
Probably the easiest way to do this is by assigning a custom key mapping to the filename autocomplete function. First, select Preferences → Key Bindings and add the following, ensuring that they are inside the outer [ ] characters (the file has to be valid JSON):
{
"keys": ["ctrl+super+alt+a"],
"command": "afn_show_filenames",
"context":
[
{
"key": "afn_use_keybinding",
"operator": "equal",
"operand": true
}
]
},
You can change the key combo to whatever you wish, just make sure it's not overwriting another Sublime or operating system key binding.
Next, open Preferences → Package Settings → AutoFileName → Settings—User and add the following line:
"afn_use_keybinding": true,
Now, to open the filename autocomplete, simply press CtrlWinAltA (on Windows and Linux) or Ctrl⌘AltA (on OSX/macOS).

How can I change the key bindings in VS Code to change the tab key to four spaces?

I'm running the latest version of VS Code and Windows 10. I'm learning Python and would like all of my indentations to be spaces. However, I'd like to use the tab key to enter those spaces.
I've tried many different variations in the keybindings.json file with no luck.
[
{
"key": "tab",
"command": "-tab"
},
{
"key": "tab",
"command": "type",
"args": {"text": " "}
}
]
With the above code, I was just trying out many spaces to check the difference. However, when I save this as the json file, it doesn't give expected behavior. It will indent the full amount, but when I backspace I'd expect it to go back one space. Yet, it backs up to where a standard tab would be.. hitting it again returns to the beginning of the line.
Is it possible for the tab key to simply be used as a macro for four spaces?
You don't need to change it in json files. You can search Tab Size in VSCode Settings and change its value to 4. If this does not work, click the Editor: Detect Indentation link and disable it. This should solve the problem.

Visual studio code - shortcut to open next file by name

I often find myself working on file test-1a.robot and I want to open test-1b.robot, which is the next alphabetical file in the editor list.
With the files are open and I have a "sort tabs" extension enabled I can use ctrl+pgup and ctrl+pgdn which is already something, but I'd like to have it even without the tab sorting or opening files in advance.
Maybe you need to train yourself in the following key combo:
Ctrl+Shift+E DownArrow Enter
I tried to use multi-command to create a combo of
show explorer tab
go to next file down
open this file
For (1.) I could find a command, it sets the focus on the current file in the Explorer.
Edit With the tip from mark for the commands to type the cursor down (2) and select command (3) in listboxes.
You can add this to your settings and create a key binding for this new command
"multiCommand.commands": [
{
"command": "multiCommand.openNextABCFile",
"sequence": [
"workbench.view.explorer",
"list.focusDown",
"list.select"
]
}
]
It opens the next alphabetical filename in preview mode.

VS Code - find panel/view context name for shortcut 'when' expression

I'm trying to add some shortcuts to my VS Code instance and I want to scope them using the when expression to avoid conflicts.
Alas, I'm struggling to find the right context name to use in the expression to achieve what I want.
I've searched the documentation and found that a number of them are listed here: https://code.visualstudio.com/docs/getstarted/keybindings#_contexts
But, as the documentation says:
The list above isn't exhaustive and you may see some when contexts for specific VS Code UI in the Default Keyboard Shortcuts.
Of course, the context to which I want to scope my shortcuts is not on the list ;)
Thus, I was wondering if there was a way to find the context name of a specific panel/view in the VS Code UI.
To illustrate this, suppose I'd like to make a shortcut active only when the panel that lists the available NPM scripts is focused... What context name should be used to achieve that?
I tried this - not expecting it to work - but it seems to:
"when": "focusedView == npm"
Similar info is active/focussed view context clauses.
In general, you can:
Open the developer tools: Help/Toggle Developer Tools and go to the console
Choose Inspect Context Keys in the VS Code Command Palette
Click on an element in the vscode window
Look in the tools console and expand the last item therein to show all the current context (when clauses).
But when I did that I didn't find anything helpful and focusedView = "" was there, so that's not helpful.
so I just tried
{
"key": "alt+i",
"command": "workbench.action.terminal.sendSequence",
"args": { "text": "howdy" },
"when": "focusedView == npm"
},
that just prints howdy to the terminal for testing.. And the only way I could get it to work was when the npm scripts viewlet header or its contents had focus.

Can I define a task for Replace Operation in vscode?

I replace every debugger; phrase with "" in my solution some times a day. I thought it could be well if there is a way to define a task for this operation.
Do you know the solution. is there this feature?
You will need a macro extension such as multi-command. It will allow you to chain commands together to run with one keybinding.
In your settings.json:
{
"command": "multiCommand.removeDebugger",
// "interval": 250,
"sequence": [
"workbench.action.findInFiles",
// "toggleSearchRegex", // depending if the default is regex on or off
// and where you want it to end up
"search.action.refreshSearchResults",
"workbench.action.replaceInFiles",
"search.focus.nextInputBox",
"editor.action.clipboardCutAction",
"search.action.replaceAll"
]
},
This will open the "Find In Files" panel. Then it will run the command to actually search for your chosen string across files (which is a necessary step before doing a replace). Then it will move to the "replace input box", clear its contents (since you want to replace "debugger;" with nothing) and run the replace in all files command. VSCode will prompt you if you really want to do it.
In your keybindings.json put some keybinding of your choice, such as:
{
"key": "ctrl+alt+u",
"command": "extension.multiCommand.execute",
"args": { "command": "multiCommand.removeDebugger" }
},
The only requirement is that you highlight the phrase you want to search for first - in your case debugger;- and then trigger it with Ctrl-Alt-U or whatever.
Here is a demo gif of it working - I slowed it way down so it could seen going through the steps:
. The gif software is wonky on the keystrokes - it is just Ctrl-Alt-U.
I have created a VSCode extension for this task. It registers a command Remove Debugger Statements bound to ctrl+alt+shift+d on windows and ctrl+cmd+shift+d on mac to perform the required action.
Additionally, it also has settings to specify the files/folders to include/exclude while performing the action.