Use ctrl-j and ctrl-k to navigate menus in Visual studio - visual-studio

I normally use vim, but sometimes it's convenient to use Visual Studio 19.
I'm trying to keep my keybindings as consistent as possible between the two.
In vim I use ctrl-p to open a file by typing its name. I switched visual studio to use the vscode keymap defaults to get this behavior (vscode also uses ctrl-p for searching by filename). However, when using the dropdown list for this search, I'd like to be able to highlight a different item by using ctl-j and ctrl-k to move up and down, similar to how fzf works in vim.
Is this a key binding I can set, and if so, what is it called?

I used AutoHotKey with this script
#NoEnv
#SingleInstance, force
#Warn
;#IfWinActive, ahk_exe devenv.exe
^h::Send {Left}
^j::Send {Down}
^k::Send {Up}
^l::Send {Right}
Capslock::Esc
;:#IfWinActive
if you want it only to happen when you have vs2019 up, then uncoment the #IfWinActive, by removing the ; , however, I want to be able to use the bindings whenever, not just in VS
You can compile the script and then put them into your start up by pressing Win-R to open the run command dialog, then entering in
shell:startup
and it will open an explorer window to your startup, just drop the exe in there afterwards, and it should start up every time.
you can also create hotkeys for doing other things, like added my VS path to my PATH environment variable, then had autohotkey assign Win-S to open up devenv.exe with this script.
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %userprofile% ; Ensures a consistent starting directory.
#s::
Run, *RunAs devenv.exe
Return

Related

ctrl+f2 keyboard shortcut does not work in VSCode on macOs

I have ctrl+f2 mapped to toggle bookmark in my vscode keyboard shortcuts.
{ "key": "ctrl+f2", "command": "bookmarks.toggle", "when": "editorTextFocus" },
It work correctly on Linux and Windows, but not on macOs.
I have enabled the setting to switch function keys (f1, f2, etc) to behave as standard function keys.
I have then unmapped ctrl+f2 in macOs keyboard shortcut settings.
But still ctrl+f2 keyboard shortcut is not registering with vscode.
Troubleshooting VS-Code Keybinding Issues
The best way to troubleshoot an issue with Keybindings in V.S. Code is to use the tool that was created for solving keybinding issues
The tool is simply named: "Keyboard Shortcut Troubleshooting Tool"
The tool comes with V.S. Code "out of the box", as a result; no downloading, or installation is needed. To use the tool you just activate it from the Quick Input Menu that drops open by pressing the F1-Key. If you cannot find it your self I posted instructions below, and an image. If you can find it yourself, then skip the "Activating the Troubleshooting Tool" Section, and go ahead and read, "Effectively Troubleshooting Issues with the Troubleshoot Keyboard-Shortcut Tool"
Activate V.S. Code's Troubleshooting Tool
Hit the F1-Key
When the quick input drops open type the following into the text input:
"Toggle Keyboard Shortcuts Troubleshooting"
Select the option: Developer: Toggle Keyboard Shortcuts Troubleshooting
It should automatically open the OUTPUT panel, which is located in the same panel that your terminal is. Make sure that the OUTPUT is set to LOG(Window) in the drop down. (I took a picture and posted it below if you can't find the Keyboard Shortcut Troubleshooter).
The image might have funny declensions because I am on a dual monitor setup with 1 1080x1920 curved screen and one 1080x720 screen.... I cropped it to a STD HD 1920 width.
HELPFUL SIDE NOTE:
"This tool may be the most verbose program ever written, as far as I can tell, it logs data to the OUTPUT Console each & every time you activate a keyboard event. Truth be told, I find this tool to be extremely distracting, and very annoying. Because of this, it is important to note, that even if you switch out of your OUTPUT console to your terminal or something. The Troubleshooter is still actively logging to the OUTPUT Console. Make sure when you are finished to turn it off."
Turning off the Keyboard Troubleshooter, requires the same process as turning it on.
Using V.S. Code's Troubleshooter
STEP-1: Close VS Code
This is not to be confused with reload V.S. Code. The only mechanism that VS-Code has for reloading its-self, doesn't provide the same functionality as closing, and reopening V.S. Code. The two are similar, but they are not equal (discussion for another time).
actually stop its process from running by hitting the X in the upper right corner of the title-bar, or hit
**[Alt + F4].
Step-2: Reopen V.S. Code W/O Any Extensions
Don't worry, you won't have to uninstall anything. You will start V.S. Code from the command-line though. Open up your bash terminal, or Powershell, and enter the following command:
$ code --disable-extensions
V.S. Code should start almost immediately
If the V.S. Code CLI doesn't open your editor, or this doesn't disable your extensions, you should refer to this link
Step-3: Start the Keyboard Shortcut Troubleshooter
I already explained this step above, so their is no reason to go over it again. Do make sure you have your panel open, and the OUTPUT tab is selected. You should see a bunch of logging being output, in the VS-Code output (that is redundant sounding), logging when you use any keybinding. The drop-down should have Log(Window) showing, as the current log selected.
Step-4: Test Your Keybinding
At this point you can use your keybinding, and get results. They might not be the results that you were hoping for, but the troubleshooter should give you details as to what is happening when you use your keyboard shortcut (aka bound-key, aka key-binding).
Step-5:
Fix the issue by opening the Keyboards Shortcuts configuration file by opening the quick input, (like I described above for the troubleshooter), and type Keyboard Shortcuts. Their will be two options, one is the default Keybindings that cannot be written too, the other is a configuration file, where you are allowed to overwrite all of the default keybindings if you choose. Look in the default keybinding.json file and make sure the keybinding that you feel is assigned to a certain task, really is assigned to it. Look in the regular keybindings.json file, and make sure if anything is written in it, that those keybindings are not affecting the keybinding that is not working for you. Use the information from the troubleshooter to help guide you through the process.
These links below further elaborate on V.S. Code keybindings:
V.S. Code Community Docs (Community Contributed)
V.S. Code Official Docs (Keybindings)

CMD-Period unexpectedly translated to ESC in IDEA apps on macos (PyCharm, GoLand, Android Studio)

I use Cmd-. (Command-Period) as a common hotkey in my IDEs (go to definition), but recently the IDEA/JetBrains IDEs have started to re-interpret this key combination as the escape key. I can't figure out what exactly changed on my system to make this start happening. There was probably an OSX update or two which happened between the last time it worked and when I noticed the new behavior.
In the IDEA keymap menus, when I hit Cmd-. in the search-by-key dialog, it inserts the Esc glyph, the the behavior of the rest of the app seems to follow suit, it's just acting like Esc.
This issue seems to be specific to the IDEA-based apps. It reproduces in PyCharm, GoLand, and Android Studio. Cmd-. still works as expected in iTerm2, Cocoa Emacs, and the OSX system shortcut settings window.
Any idea of how I can bring back Cmd-., or at least interpret it as something other than Esc?
Unfortunately, there's no way to stop interpreting Cmd-. as Esc. However, as a workaround, you can try assigning the shortcut in a keymap XML file.
It may help in some cases, e.g. it works for opening tool windows, but it doesn’t work with Find in Path because sometimes the dialog gets closed (both meta . and Esc are invoked).
In Preferences | Keymap, set some shortcut to the desired action, and exit IDE
Open settings directory: https://intellij-support.jetbrains.com/hc/en-us/articles/206544519
Open a keymap XML file under "keymap" directory
Find the action changed in step 1, and change the "first-keystroke" parameter of the "keyboard-shortcut" node to "meta period". So it will look like:
<keyboard-shortcut first-keystroke="meta period" />

Passing alt-tab to Emacs inside Screen inside Putty

I run terminal-mode Emacs (using the -nw option) inside Screen on my office Debian box. This way, I can log in my box with ssh from anywhere and work even with slow or intermittent connection.
When I log in from Windows using Putty, I miss the possibility of using the Alt-Tab key combination (M-TAB in Emacs parlance). I compensate using the two keys Esc and Tab, but that's two key presses, which is slower.
I just discovered that using Autohotkeys I can make Ctrl-Tab do the same as Alt-Tab with this rule:
LControl & Tab::AltTab
and I can disable Alt-Tab altogether with this other rule:
!Tab::Return
but this is not what I want. I need to copy the functionality of Alt-Tab on some other hot key (Ctrl-Tab is okay and the first rule does that) and additionally I want the Alt-Tab key to be passed to Putty when I am using it (which would pass it to Screen, which would pass it to Emacs). In other words, Alt-Tab should not be disabled, but its special meaning should be deleted.
Is this possible with Windows?
While I don't fully understand the issue you're encountering, this framework should give you something to work with for conditional actions based on the window.
!Tab::
{
WinGetTitle, Title, A
if (RegExMatch(Title, "PuTTY.*"))
{
; Do something if PuTTY is the active window.
}else{
; Do something else if PuTTY is NOT the active window.
}}
Working with the answers I got from several hepful users, I got to the final solution I have used for some time now. Here is the Autohotkeys script that I put on my desktop and that I double-click every time I have to restart Windows:
File "alt-tab to ctrl-tab.ahk"
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
LControl & Tab::AltTab
; !Tab::Return
; #IfWinActive, putty
!Tab::send {Esc}{Tab}

Reuse window / tab when file is already open

I want to set a global shortcut that will open a certain file. When there already is a gvim window that has that file open, I want it to focus on that window, and select the tab with that file. If there isn't, I want it to be opened in a new gvim window, regardless of whether there already are other gvim windows.
I can do part of this with --remote and --servername, but I can't find a way to detect whether there already is a remote server running with the name I use, so I can't quite get everything to work together to come to what I described above.
OK, turns out most can be done using the default behavior of --remote-silent. The whole setup is a matter of making an AutoHotkey script like this:
#!^+1::
Run "c:\Program Files (x86)\vim\vim74\gvim.exe" --servername org --remote-silent %DROPBOX%\org\TODO.org
WinActivate, TODO.org
Return
AHK is needed for the global hotkey as well as activating the window; vim (using --servername and --remote-silent) will start a new session called 'org' if there isn't one yet, and start it otherwise. It even gets the tab activation right when there already is a server called 'org' but if that server has another tab active.

Script to remove hotkey for internet-shortcut in windows

Everytime I start my computer the login-scripts create a shortcut in the start menu which also defines a hotkey for it. Unfortunately this hotkey collides with one of the default eclipse hotkeys so every morning I manually remove the hotkey from the shortcut.
Deleting or manipulating the shortcut doesn't remove the hotkey as well.
So how can the hotkey be removed with a script?
To be precise the shortcut is a shortcut to an URL. The file has the suffix .url.
The structure of the file seems to be an basic windows info file:
[InternetShortCut]
URL=http://...
...
Hotkey=1620
...
I am using Windows XP.
maybe some tweaking on the msconfig's startup and services tab can do some help

Resources