Scrolling through Visual Studio Intellisense list without mouse or keyboard arrows
Asked Answered
A

6

44

I'm a heavy user of Intellisense in Visual Studio. I'm also a "keep your hands on the keyboard" and "keep them in home position" aficionado, so I'm always looking for ways to keep my hands centered on the ASDF   JKL; keys as much as possible.

Whenever the Intellisense list pops up in Visual Studio, if there are many words in the list that start with the same letters as the word I'm trying to select, typing the first few letters to hone in on my selection doesn't help, since the list won't jump down to my preferred selection until I type enough characters to finally reach the first unique character in the word. It's usually faster to take my right hand off the JKL; keys and reach for the up/down arrow keys to manually scroll through the list.

I'd rather keep my hands centered in home position, and ideally use something like the J and K keys to move up and down in the Intellisense list (similar to how J and K move up and down in Vim...and especially since I use VsVim inside Visual Studio).

The MSDN Intellisense documentation only lists the up/down arrow keys and scrolling (mouse wheel, PgUp/PgDn keys, etc.) as options for doing this: enter image description here


So here are my questions (in order of preference):

  1. Are there any existing keyboard shortcuts in Visual Studio that allow keeping your hands in home position while scrolling the Intellisense list?

  2. Is there any way to custom map keyboard keys (such as J and K) to do the up/down scrolling in the Intellisense list?

  3. Are there any plugins that enable this functionality?

  4. Is there any other way to accomplish this?

Attempt answered 9/8, 2013 at 18:44 Comment(17)
You can create your own extensions to Visual Studio and perform nearly any improvements you can imagine, using the Visual Studio SDK, but that is a huge topic (which I'm just beginning to learn right now)Miceli
very nicely written question by the way...Surgical
@HighCore Yes, and a task I'd rather not take the time to tackle right now! (though I've been really inspired by VsVim and how helpful it is to me on a daily basis...maybe someday?)Attempt
Couple questions, why are you an aficionado of keeping your fingers in the home position on the keyboard? Is it because you think you can work more efficiently that way or because it's ergonomically more comfortable for you? Also, if you used J/K to scroll without any modifier key, how would the system know whether you are still trying to type the first few letters of the name or are attempting to scroll?Acrid
@DanM It's all about efficiency. And your question about using J/K without a modifier is very insightful...you're right...how would VS know the difference? Using a modifier (such as Ctrl+J) would be perfectly acceptable to me (I have remapped my CapsLock to Ctrl so it is almost effortless to reach)Attempt
@DanM I assume he means something like ctrl+J or ctrl+K, since that allows you to keep your fingers in the home position. That's what I'd like anyway.Ectomere
RSW, I definitely won't try to talk you out of what you're trying to accomplish, but you might find this post interesting: asktog.com/SunWorldColumns/S02KeyboardVMouse3.html.Acrid
And, if you enjoyed that one, a couple others: codinghorror.com/blog/2008/03/…, ux.stackexchange.com/questions/30682/….Acrid
@DanM The first article is interesting, but flawed as a comparison. The author Tog was comparing manually moving around a document using the keyboard arrow keys vs. pointing-and-clicking to get where you were going. Yes, that would be twice as slow, as he found. I use keyboard remappings, custom AutoHotKey macros, and VsVim for my editing, so the test he speaks of where the mouse took 50 seconds would have taken me about 5 (single VsVim command: :%s/e/|/g)...Attempt
@DanM ...Even if I used the keyboard to manually navigate to each letter "e" in the paragraph and do a direct replacement, it would still only have taken about 5 seconds (/e to navigate to first letter "e", r| to do the replace, n key followed by . key to repeatedly find/replace all other "e" characters in the paragraph. Lightning fast. Plus, when coding intensively, it's not just the physical time it takes to reach for the mouse, it's the potential break in concentration to do so (not the case for everyone).Attempt
@DanM And the codinghorror article states "However, as Tog himself notes, when the keyboard shortcut is already memorized and well understood, it's a clear productivity win." For the casual computer user, stick with the mouse. For the guy who codes at his computer 8+ hours a day, I'll spend a couple of days committing my keyboard shortcuts to memory any day of the week to reap those "clear productivity wins" for the rest of my career.Attempt
My intention was just to share some research on the parameters that affect productivity (some of which may be surprising to you), not to sell you on any particular solution. It definitely makes sense to try to speed up Intellisense selection because that is a nearly constant thing programmers do. Will caps-J/K end up being faster than arrow keys? I would expect not right away, but with some hours of practice, probably yes. One other idea to consider: R#'s "camel humps", where you type inpc to bring up INotifyPropertyChanged in the Intellisense menu.Acrid
@DanM I tried using the camel case trick (works natively in VS too), but found it both slow (because I had to look for each capital letter) and it failed as soon as an underscore character appeared in the word. Appreciate the creative idea though!Attempt
Regarding Tog's experiment, of course, any find/replace mechanism would be faster than manually replacing each pipe with an "e". The point of the experiment was that, if you need to place the cursor in a particular location in a text document, the mouse is faster than cursor keys. Regarding Vim, the trade-off is that each command requires thousands of repetitions to become truly well-learned. You will probably become very fast with the ones you use constantly but slower than "GUI" for the remaining ones. You may or may not end up faster in the end, but I have no doubt, you'll feel faster :)Acrid
@DanM Much of vim is faster because I started on vi back in the late 80's as a teenager developing professionally on Unix boxes. It's like riding a bicycle to me now. For find/replace in VS, I still primarily use the built-in refactoring to handle renames instantaneously, or for true find/replace I do use Ctrl+F or Ctrl+Shift+F, because I like to step through each find/replace manually and inspect the proposed changes. So that's already slower for me by design, since I'm analyzing each change individually.Attempt
@DanM But yes, I agree that for direct cursor placement, the mouse is fastest. But overall, for me, rapidly moving around the document in Vim and never (or rarely) having to break flow by moving to the mouse and back (hundreds of times a day) does end up faster. Or as you say, "at least it feels faster"!Attempt
If you're all about efficiency, you should switch to Dvorak keyboard layout; best decision of my lifePreceptor
P
41

I have remapped CTRL+P to Edit.LineUp and CTRL+N to Edit.LineDown and this works in the Intellisense dropdown. For some reason the Intellisense dropdown dims out when pressing CTRL so it gets kind of hard to see the content in the dropdown. It's not a big problem though, since you can always release CTRL and it will light up again. I mostly use this method when I don't know the name of the method and want to browse for it.

If I know the name or part of the name it is often quicker to just type some of the letters in the method name. If I know for example that the name of the method I want is GetHashCode then I would just type "geh" or "has" or similar since that would be matched by intellisense.

Polythene answered 11/9, 2013 at 14:50 Comment(4)
The dimming is a usability feature they added sometime around VS 2010. Intellisense would have a nasty habit of obscuring exactly the code you wanted to look at, which meant you had to close intellisense, read the code, and then reopen intellisense. Now, with a simple Ctrl press, it turns transparant so you can quickly read your code and let go of the key again, without leaving intellisense.Tailing
Hallelujah!! I didn't think anyone was going to solve this! Following your tip, I chose to use Alt+J and Alt+K which is closer to the J/K keys I use in Vim for up/down. Also, the Alt key doesn't dim the Intellisense window like Ctrl does. But the key thing here is that you identified the Edit.LineUp and Edit.LineDown commands as the source of the solution. So excited...thank you!Attempt
You can also setup Edit.CharLeft and Edit.CharRight to fully get rid of arrows keys. (I guess you already know this, but still...)Baikal
Edit.LineUp and Edit.LineDown are gone in VSCode 1.4.2; they should be selectPrevSuggestion and selectNextSuggestionVanzandt
E
11

Go get a used Kinect for $30 and map either a voice command or a head gesture to mouse scroll event. The SDK is really easy to use. You could say if head tilt left scroll up or right scroll down.

SDK http://www.microsoft.com/en-us/kinectforwindows/develop/developer-downloads.aspx

Documentation http://www.microsoft.com/en-us/kinectforwindows/develop/learn.aspx

Example Projects http://channel9.msdn.com/coding4fun/kinect

You're only limited by your imagination.

Extended answered 9/8, 2013 at 19:27 Comment(3)
Wow! Very creative idea! Bravo for thinking outside the box! I can't see myself wanting to use this approach, as the keyboard fits my style so much better, but I must say this is pretty brilliant. +1Attempt
@Attempt Thanks, I can't take to much credit though. People have been hacking that thing forever. There are some really cool projects out there. My favorites are the ones were people recreate their room in 3D Dynamically with 2 Kinects perpendicular to each otherExtended
My coworkers are going to love my new intellisense navigation voice commands!Monolingual
T
3

I'm not sure which keyboard you prefer to use, but would an option be getting a keyboard with a thumb-accessible scroll wheel? Or something like the Microsoft Natural Ergonomic 4000, which is a pretty great keyboard on its own but has a zoom-slider that's accessible to your index fingers on the home row. With some work you can change the zoom functionality to scrollup and scrolldown.

Tailing answered 11/9, 2013 at 15:7 Comment(0)
M
3

I was looking to accomplish the same that Doktorn suggested in Visual Studio Code, so I will put the solution here just in case someone needs the same.

You have to add two new Key bindings in keybindings.json:

[
    { "key": "alt+j",                    "command": "selectPrevSuggestion",
                                         "when": "suggestWidgetVisible" }, 
    { "key": "alt+k",                    "command": "selectNextSuggestion",
                                         "when": "suggestWidgetVisible" }                                                                                 
]
Mescaline answered 3/7, 2017 at 19:58 Comment(3)
perfect, just what I was looking for!Monophthong
Thank you so much; the top answer Edit.LineUp and Edit.LineDown no longer exist. I think they are changed to what you suggested selectPrevSuggestion and selectNextSuggestionVanzandt
it just does not work on my machine. do you know what may be the cause? I did exactly that + no conflict key.kLuckin
M
0

This!

When my hands leave the keyboard, 90% of the time it's for the arrow keys, often to accept an intellisense suggestion.

So Autohotkey. The script below gives me arrow keys that work the same in all applications! I put them on the top row, right hand to minimise collisions while still being ergonomic. One script does the same thing in SSMS, Visual and Visual Code, and everything else.

ctrlu up

ctrli down

ctrlo left

ctrlp right

Works like a charm. This has become absolutely fundamental for me. The only friction is that by default it will run with normal privileges, so it won't be available in programs you launch as administrator. If you want, set autohotkey to run as administrator. You will have a UAC prompt every time it starts, but you'll have your arrow keys all the time. Autohotkey intercepts the key combos before the app gets them, so you will lose app shortcuts mapped to these keys. In VS Code, ctrlp is essential, but ctrle does the same thing. ctrlp is Print in many other apps, but when was the last time you printed anything?

# ArrowKeys.ahk

^u::
Send,{up}
Return

^i::
Send,{down}
Return

^o::
Send,{left}
Return

^p::
Send,{right}
Return
Minimal answered 31/1, 2020 at 0:4 Comment(2)
"I put them on the row upstairs to avoid collisions" I have no clue what you mean by this. What file are you talking about? thanks in advance other solution does not solve my problem.Luckin
The code above is an autohotkey script that maps ctrl-u to the up arrow, ctrl-i to the down arrow and so on. You need to download and install autohotkey, then paste the code into the default script. I chose the top row of the keyboard to avoid clashes with other shortcuts, but you can customise this if you don't like it. It means I have arrow keys without having to lift my hands from the home position.Minimal
C
-1

This method is working in VSCode for Windows 10, latest version. Works just like up and down arrows.

    {
        "key": "alt+j",
        "command": "selectNextSuggestion",
        "when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
    },
    {
        "key": "alt+k",
        "command": "selectPrevSuggestion",
        "when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
    }
Cann answered 28/8, 2019 at 23:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.