Sublime Merge - keyboard shortcut for "File History" - sublimemerge

How can I make a keyboard shortcut for Navigate > File History... in Sublime Merge?

The command for this is file_history; it will prompt you interactively in the command palette and commands of that nature need to be invoked via the show_command_palette command.
So, a key binding that duplicates what the menu item Navigate > File History... does would look like the following (using an example key; change that as desired):
{
"keys": ["ctrl+alt+t"],
"command": "show_command_palette", "args": {"command": "file_history"}
},
This binding goes into the Default (<PLATFORM>).sublime-keymap file in your Merge User package, where <PLATFORM> is one of Linux, Windows or OSX depending on what platform you're using.
You can locate the User package by choosing the Preferences > Browse Packages command from the menu and then navigating inside of the User package.
Note that just like Sublime, the sublime-keymap file is a JSON file that is a list of key bindings; thus if you don't already have key bindings, you need to wrap the key binding above in [ and ] characters to make it the first item in the list.

Related

How do i add a git: link reference in vs code help menu?

When i cmd + shift + p i get the following screen in vs code
One of the options i see is keyboard shortcut references, When i click on this link , it opens a tab in the browser which showcases all the keyboard shortcuts.
Now i'd like to add a similar link titled Git: Open Aliases with a link that goes to HERE. How do i do this ?
The functionality of the IOpenerService is in the API as vscode.env.openExternal
You can use the extension HTML Related Links v0.14.1
Use the command htmlRelatedLinks.openURL it works the same as the Ctrl-Link-Click. You get the Trust dialog.
Define a keybinding
{
"key": "ctrl+i ctrl+g",
"command": "htmlRelatedLinks.openURL",
"args": "https://raw.githubusercontent.com/GitAlias/gitalias/master/gitalias.txt"
}
If you want a command in the Command Palette you have to define it in the package.json file of an extension. In this file is the string used to display in the Command Palette.
In this extension I have defined a command to open the GitAlias page and show the command in the Command Palette as: Git: Open Aliases
You can set a key binding for this command.

ctrl-e to switch between two files in visual studio code

Most people use alt+TAB to switch between applications on their desktop.
This question is about switching between two windows in Visual Studio Code.
I am used to use ctrl-e to switch between two files in PyCharm and Chrome (via plugin Quick Tab).
Now I would like to do the same in vs-code.
The short cut ctrl-e opens the change file dialog. But if I hint "enter", I stay in the same file. I would have to use the down-arrow key to change the file.
Since I can blindly switch between two files in PyCharm and Chrome with ctrl-e ENTER, I would like to do the same in vs-code. How can I configure it this way?
In your keybindings.json:
File > Preferences > Keyboard Shortcuts. "Open Keyboard Shortcuts" (top right).
{
"key": "ctrl+e",
"command": "workbench.action.quickOpenPreviousRecentlyUsedEditorInGroup"
},
{
"key": "ctrl+tab",
"command": "-workbench.action.quickOpenPreviousRecentlyUsedEditorInGroup"
},
See this issue: https://github.com/Microsoft/vscode/issues/6923
I found workbench.action.showAllEditorsByMostRecentlyUsed to be the most like JetBrains Rider / Intellij although a extra 'Down' keystroke is needed afterwards. It shows the most-recently-used editors and does not disappear when I release the shortcut chord.
Steps:
File | Preferences | Keyboard Shortcuts
Paste workbench.action.showAllEditorsByMostRecentlyUsed in the search at top
Replace the existing binding with Ctrl+e
Remove other Ctrl+e bindings if necessary

A keybindings.json per workspace in Visual Studio Code

Is it possible to have a keybindings.json as part of the workspace settings instead of the user settings?
Since I have specific tasks associated to my workspace, I would also like to be able to assign workspace-specific shortcuts. Because I would use these shortcuts on my separate Windows and Linux environments, I would not prefer to see these key binding definitions end up amongst my environment-specific user settings.
This is not possible. Here Alexandru Dima (alexandrudima) explains why they do not want to add this feature and furthermore suggests to create your custom extension that contributes only keybindings to share them.
Not a perfect solution, but I found a workaround to create a keybinding that can be activated at a workspace level.
In the workspace .vscode/settings.json file, set a new setting to true. (Because the setting is not registered by vscode or any extension, it will be displayed faded out in the editor - This is OK):
"workspaceKeybindings.myAwesomeTask.enabled": true // setting can be anything you want
Then create the keyboard shortcut in the user keybindings.json, and add a "when" condition for the setting you created:
{
"key": "ctrl+; ctrl+n",
"command": "workbench.action.tasks.runTask",
"args": "My Awesome Task",
"when": "config.workspaceKeybindings.myAwesomeTask.enabled" // Must be "config.{settingName}"
},
This keybinding can be set as active in any workspaces you want.
as of July 10, 2022, it doesn't seem possible to have a .vscode/keybindings.json per workspace, however it is possible to get keybindings that are active only when you're in a certain folder:
In your keybindings file, you can put:
[
{
"key": "...",
"command": "..." ,
"when": "resourceDirname == '/Users/johndoe/path/to/folder'",
...
},
]
You also have all these other contexts:
resource: "vscode-userdata:/Users/johndoe/path/to/file.json"
resourceDirname: "/Users/johndoe/path/to/"
resourceExtname: ".json"
resourceFilename: "file.json"
resourceLangId: "jsonc"
resourcePath: "/Users/johndoe/path/to/file.json"
resourceScheme: "vscode-userdata"
and more...
To find all possible context keys:
Run the Developer: Toggle Developer Tools vscode command
Then run the Developer: Inspect Context Keys vscode command and then click anywhere
Expand the context object in the console, and you should see a full list of context key-value pairs

How to add multiple terminals in VS Code?

Can we add multiple different terminals in the VS Code? I am planning to add following three terminal and work with all of those :
Windows Command prompt
PowerShell
Git Bash
I know I need to add the following command in Preferences => Setting
// // 64-bit cmd if available, otherwise 32-bit
"terminal.integrated.shell.windows": "C:\\Windows\\sysnative\\cmd.exe",
// // 64-bit PowerShell if available, otherwise 32-bit
"terminal.integrated.shell.windows": "C:\\Windows\\sysnative\\WindowsPowerShell\\v1.0\\powershell.exe",
// // Git Bash
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
I want to add all of the above three commands in setting.json
And when I click + different terminal should open and I want to work with those terminals without changing the preferences.
Is it possible in VS Code or not?
There is a way to make this happens with these steps by installing an extension:
Find an extension called Shell launcher and install it or you can find it here. Reload VS Code if you want or after you finished all steps.
Go to Files --> Preferences --> Settings and this will open settings.json file and you then insert this (you can edit this to your heart's content):
Code:
"shellLauncher.shells.windows": [
{
"shell": "C:\\Windows\\<sysnative>\\cmd.exe",
"label": "cmd"
},
{
"shell": "C:\\Windows\\<sysnative>\\WindowsPowerShell\\v1.0\\powershell.exe",
"label": "PowerShell"
},
{
"shell": "C:\\Program Files\\Git\\bin\\bash.exe",
"label": "Git bash"
},
{
"shell": "C:\\Windows\\<sysnative>\\bash.exe",
"label": "WSL Bash"
}
]
PS: You can use shellLauncher.shells.linux for Linux or shellLauncher.shells.osx for macOS.
Go to Files --> Preferences --> Keyboard Shortcuts and then find on {} icon on the top right corner to open keybindings.json file. Insert this:
Code:
[
{ "key": "ctrl+alt+`", "command": "shellLauncher.launch" }
]
Update: Type shelllauncher into the search bar. You can then see Shell Launcher: Launch command. Highlight and use any keybinding you like. For example, I picked Ctrl + Alt + (backtick)` for myself.
You can reload your VS Code and click the key combination you have assigned and that will give you the option to choose which integrated terminal you want to use.
For more details, please check the official site: https://marketplace.visualstudio.com/items?itemName=Tyriar.shell-launcher
Enjoy!
Even the question is asked last year and the answer is accepted but still I feel to answer this question as I didn't found any simple, suitable and complete answer while as a development I need multiple terminal handy in a click like below:-
and I don't bother about their path, add another extension for what the VS Code is already capable of or reload VS Shell etc and go to insert and setup the settings files manually.
I found this question is asked many times and almost all landed up manually setup of write some settings etc. or sometimes only opted to get a single type of terminal. The answer of #Pawan is somewhat near but again that solution finally land up to a single terminal, going to command setup for switch terminal and this one will work for git or any other terminal.
If you have tools installed which worked on command line like power-shell and git along with default cmd prompt in windows then the follow the quick three steps to get all terminals at once and switch to anyone with a click.
Open terminal, it should be visible (use ctrl+` or from menu View-> Integrated Terminal )
Open commands search (use Ctrl+Shift+P or from menu View->Command Palette...)
In command box Type "Terminal: Select Default Shell" to select this option from drop down.
As you select this option, then all the available commands which are in path will be listed below like below
Just click any one which you like to add for quick access from command list.
Finally, in the terminal window, just click on + sign next to terminal list as shown below:-
The terminal selected in step 5 will now added after performing step6 to the list without removal of earlier terminal.
Repeat step 3-6 for adding any other terminal to command list.
To work with particular terminal just select the required one in the terminal list of the terminal window.
press ctrl + shift + ` shortcut, or press a cross sign to run new terminal, then type bash if your default mode is powershell or powershell if your default mode is bash. And here you are, your terminal is switched.
For now VS Code support defining only one of available terminals as default at a time and you can not add multiple shell terminals.
If you don't want to install "Shell Launcher" plugin as suggested by #ian0411 then here is a quick way to change/select default terminal.
Press "Ctrl + Shift + P" to open the Command Palette.
Type "Terminal: Select Default Shell" and hit enter. You will be prompted to select Git Bash, PowerShell or Cmd as shown below:
Note: This will change the default shell terminal but there is no harm changing it whenever you need to use another.
BTW, if you need to switch only between Cmd & Powershell then you can type cmd or powershell (in already opened terminal) to switch to desired terminal. But it would not work for Git Bash.
I don't see this in the above, but read all the answers. I think this is the best approach for what is supported right now. I believe, like myself, the OP simply wants to open VSCode, and down yonder on the terminal window, we just want a list of options to open from.
Yes, you can open the command, "Terminal: Select Default Shell" and loop through that to add various types of terminals...
Followed by:
I don't know when this option was added to the dropdown, but look! No need to start by looking up the command. I think this is a lot smoother than any other answer, but it still results in the annoying overwrite of your default term to whatever your last choice was before leaving session.
Here, we can more easily open the Select Default Shell - it should support "Select New Shell". Simple, you'd think. Hopefully someone adds that soon or I have time to contribute.
I'm fairly certain that these are old-style settings.json and won't work as discussed in VS Code 2021. The new style looks like:
...
"terminal.integrated.profiles.windows":
{ "Bash":
{ "path": ["C:\\Programs\\Git\\bin\\bash.exe"],
"icon": "terminal-bash",
},
"Command Prompt":
{ "path": ["${env:windir}\\System32\\cmd.exe"],
"args": [],
"icon": "terminal-cmd"
},
"PowerShell":
{ "path": ["C:\\Programs\\PowerShell\\pwsh.exe"],
"source": "PowerShell",
"args": [],
"icon": "terminal-powershell"
},
},
"terminal.integrated.defaultProfile.windows": "Bash"
...
That will get you access to Command and PowerShells and set bash as the default shell (my preference). If you want to launch a standalone application like git-bash, you will need something else.
As of https://code.visualstudio.com/updates/v1_35 you can now:
select from the pulldown menu directly above the terminal "Select Default Shell"
select the one you like
click the +
done
(the same goes for opening split screen: before this do 1 + 2 and then click the split screen button)
(although overriding the default but does no longer matter if this is your flow)
This can be done by adding a different key at the end. By just changing your example to:
// // 64-bit cmd if available, otherwise 32-bit
"terminal.integrated.shell.windows": "C:\\Windows\\sysnative\\cmd.exe",
// // 64-bit PowerShell if available, otherwise 32-bit
"terminal.integrated.shell.windows2": "C:\\Windows\\sysnative\\WindowsPowerShell\\v1.0\\powershell.exe",
// // Git Bash
"terminal.integrated.shell.windows3": "C:\\Program Files\\Git\\bin\\bash.exe",
Note that the key ...shell.windows is changed to ...shell.windows2 and ...shell.windows3.
Follow-up finding: I've noticed that once restart of the IDE, only the first terminal gets displayed. I had to reopen the settings and save it once to get both the terminals again. Will post if any better solution available.
In the terminal tab, there's a Split Terminal button. Works like a charm
To open the multiple terminal please check the screen shot for the same(on the right bottom of the visual studio code their will be a dropdown and just after it, their is +(plus) icon . On pressing it the new terminal will open.).
The recommended way to automatically open multiple terminal windows is to use the Tasks feature. See Automating launching of terminals in the VS Code documentation.
For WSL Ubuntu on Windows terminal:
File -> preferences -> settings -> click code icon in top right
Enter the following:
{
"terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\wsl.exe",
"git.enableSmartCommit": true
}

VSCode: How do I set keyboard shortcut for Show All Opened Editors in Quick Open (edt command)

cmd+p (ctrl+p on windows) searches files in current project and if I want to search currently opened files I can do cmd+p and then type edt (one of the commands they show you when you press ? to list available commands)
vscode available commands from command palette
Is there a way to create a keyboard shortcut to open the command palette with edt pre-filled? Just like open symbols with # pre-filled. In Sublime I can write "args": {"text": "#"} in the setting json file but I can't find anything similar in VSCode, any ideas?
In vscode version 1.30.2
You can go to menu File -> Preferences -> Keyboard Shortcuts
And go to Show All Editors
The default is: Ctrl + K Ctrl + P
Never mind, I only found out this command in default keybindings after I've made this post...
{ "key": "alt+cmd+tab", "command": "workbench.action.showAllEditors" },