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

454 views Asked by At

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?

1

There are 1 answers

0
Will Ehrendreich On

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