VSCodeVim / Vim

:star: Vim for Visual Studio Code
http://aka.ms/vscodevim
MIT License
13.98k stars 1.32k forks source link

Moving up and down inside an auto-completion box through Vim keys (j and k) instead of arrow keys. #2382

Open DevotionGeo opened 6 years ago

DevotionGeo commented 6 years ago

FEATURE REQUEST: A feature which will make life inside the editor, of every VSCodeVim user, 100 times easier!

What happens: When we start typing some letters and intellisense opens the auto-completion box, if the choices are more than one and our required option isn't under selection, we have either to type more letters to filter further and have our required member selected or press arrow keys to choose the required member manually and then press tab to insert it. Sometimes we even lose the choice of typing more characters to further filter. This kind of situation occurs in cases when we have a snippet and we have already completed the prefix for that snippet. For example the following snapshot. 01a

In the example above I have already completed typing the prefix (la) for an embedded elixir snippet, but as another member (Emmet Abbreviation for label tag) is above the required member, so I have to press the down arrow key to choose the required member.

(Important) Now if I press Escape key, it will discard the auto-completion options altogether and will take the editor (from the insert mode) to the normal mode. 02

What do I wish to happen: I wish that inside the auto-completion box, while being in the above situation (more than one members, and the required member isn't under selection), if I press Escape key, the editor don't go back to the normal mode, but it temporarily map j and k keys to to down and up arrow keys respectively, until I get out of the auto-completion box by either pressing tab to insert a member, or press Escape again to get out of the auto-completion box myself.

Thank You so much for this awesome plugin!

Chillee commented 6 years ago

I'm a bit confused what the purpose of this would be. Do you not want to use down and up?

If so, you can use Ctrl n and Ctrl p.

DevotionGeo commented 6 years ago

@Chillee , let me update the title to make it clearer.

DevotionGeo commented 6 years ago

@Chillee I didn't know about Ctrl n and Ctrl p, which are handy. Thank you for that! But I'd still want to have the option I proposed. It will make the editor a paradise for VSCodeVim users, because moving up and down through j and k is such a luxury!

IanEdington commented 6 years ago

Ctrl n and Ctrl p is standard in vim (next prev). This would break that paradigm.

DevotionGeo commented 6 years ago

@IanEdington But we are only adding an extra option, we'are not removing Ctrl nand Ctrl p if someone wants to use that instead. Everyone with VIM emulators inside Sublime/Atom/VSCode mixes commands. For example I sometimes save a file with Ctrl s, and sometimes save it with Escape -> :w -> Enter (the Vim way).

Thank You for the response!

Chillee commented 6 years ago

@DevotionGeo TBH, it's unlikely that we'll add this feature. It seems very niche. However, if it attracts enough attention at some point, it may be worth considering.

DevotionGeo commented 6 years ago

@Chillee It's OK. I'd have to practice Ctrl n and Ctrl p more. :)

insominx commented 6 years ago

Ctrl n and ctrl p are great for that autocomplete. Is there way to select different function signatures too?
image

davidnorthetal commented 6 years ago

There's a bunch of vim-plugins (e.g.: ctrl-p) and external-programs like FZF that already use <c-j>/<c-k>.

Why shouldn't this be customizeable? How would supporting <c-j>/<c-k> next to <c-n>/<c-p> "break that paradigm"? When it's exactly what e.g. FZF does?

Bump.

Chillee commented 6 years ago

@davidnorthetal Nothing wrong with mapping <c-j>/<c-k> to up/down. OP was proposing that within autocomplete, you could press escape, and then use j/k to navigate up and down.

@insominx Not currently. It's the command showNextParameterHint, but we don't currently have anything mapped to it. I suppose it would make sense to have it also be mapped to <c-n>/<c-p>. What do you think?

insominx commented 6 years ago

@Chillee There is precedent for it so it would be consistent with that. Also, good ways to deal with vscode popups or other editor features make the integration that much better. 👍

Chillee commented 6 years ago

@insominx Unluckily, this is actually kind of tricky to do. <ctrl-p> needs to be bound to 3 different things: the file switcher, going to next autocomplete suggestion, and going to next parameter hint.

The way things are currently set up, this is surprisingly difficult.

LeonardoDaLuz commented 2 years ago

I'm a bit confused what the purpose of this would be. Do you not want to use down and up?

If so, you can use Ctrl n and Ctrl p.

I'm suffering a lot here, this saved it. Very counter-intuitive this control N and Control P, if hjkl would be more intuitive.

cbejensen commented 4 months ago

I don't think Escape should move focus to the autocomplete (seems unintuitive), but if you just want <Ctrl-j/k> to work, you can use keybindings.json (not sure how much of these when values are totally necessary, but it works):

  {
    "key": "ctrl+j",
    "command": "selectNextSuggestion",
    "when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus || suggestWidgetVisible && textInputFocus && !suggestWidgetHasFocusedSuggestion"
  },
  {
    "key": "ctrl+k",
    "command": "selectPrevSuggestion",
    "when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus || suggestWidgetVisible && textInputFocus && !suggestWidgetHasFocusedSuggestion"
  },