Vim: Can't leave terminal panel with keybindings

Created on 10 Feb 2018  路  12Comments  路  Source: VSCodeVim/Vim

FEATURE REQUEST

What happened:
I use keybindings to navigate between tabs, panels and the sidebar. But once I move into the terminal, the keybindings don't function anymore. ( I guess the terminal doesn't forward it to vs code?)

What did you expect to happen:
I want to switch to a different panel from the terminal, while my active panel is the terminal. Currently I use "<C-p>", "<esc>", which opens the command line, and then exits it again, sending me back to the panel before I entered the terminal.

How to reproduce it (as minimally and precisely as possible):
"<C-w>", "j" into terminal, "<C-w>", "k" won't go back.

Environment:
Arch Linux, urxvt terminal with zsh inside vs code

  • Extension (VsCodeVim) version:
  • VSCode version: 1.20.0
  • rxvt-unicode (urxvt) v9.22
  • zsh 5.4.2
help wanted kinenhancement

Most helpful comment

@Chillee here you go:

    {
        "key": "ctrl+h",
        "command": "extension.vim_navigateLeft",
        "when": "vim.active && vim.use<C-w>",
    },
    {
        "key": "ctrl+j",
        "command": "extension.vim_navigateDown",
        "when": "vim.active && vim.use<C-w>",
    },
    {
        "key": "ctrl+k",
        "command": "extension.vim_navigateUp",
        "when": "vim.active && vim.use<C-w>",
    },
    {   "key": "ctrl+k",          
        "command": "workbench.action.focusActiveEditorGroup", 
        "when": "terminalFocus" 
    },
    {
        "key": "ctrl+l",
        "command": "extension.vim_navigateRight",
        "when": "vim.active && vim.use<C-w>",
    }

(I got this from https://github.com/VSCodeVim/Vim/issues/2092)

All 12 comments

Would love to see this! Taking it a step further I would love this to also work with tmux.

So I can use the same command to move around tmux AND vscode panels 馃挴

I use this in keybindings.json so i can use ctrl+k to jump back to the last editor:

    {  
       "key": "ctrl+k",          
        "command": "workbench.action.focusActiveEditorGroup", 
        "when": "terminalFocus" 
    }

(I use ctrl+h/j/k/l to move around)

The reason this happens is that in the terminal, <ctrl-w> is captured and sent to the terminal instead as "delete a word". The best solution is to do something like what @parherman said.

It's possible we could add a binding, but I don't see one that would satisfy all use cases.

Thanks @Chillee and @parherman!

@parherman Do you mind sharing all the bindings needed for ctrl+h/j/k/l?

Thanks!

@Chillee here you go:

    {
        "key": "ctrl+h",
        "command": "extension.vim_navigateLeft",
        "when": "vim.active && vim.use<C-w>",
    },
    {
        "key": "ctrl+j",
        "command": "extension.vim_navigateDown",
        "when": "vim.active && vim.use<C-w>",
    },
    {
        "key": "ctrl+k",
        "command": "extension.vim_navigateUp",
        "when": "vim.active && vim.use<C-w>",
    },
    {   "key": "ctrl+k",          
        "command": "workbench.action.focusActiveEditorGroup", 
        "when": "terminalFocus" 
    },
    {
        "key": "ctrl+l",
        "command": "extension.vim_navigateRight",
        "when": "vim.active && vim.use<C-w>",
    }

(I got this from https://github.com/VSCodeVim/Vim/issues/2092)

@parherman thanks for you help. It doesn't really work for me. I placed the bindings you proposed in vim.otherModesKeyBindingsNonRecursive.
The weird behavior is that now I have to press every button (h/j/k/l) twice in order to move one character further.
Moving between windows doesn't work.

@CodingJonas You should put them in keybindings.json, it a general file for all keybindings in vscodo

Thank you, that fixed it!
It was just too obvious :D

@Chillee Are you sure that the terminal consuming ctrl+w is the root of the problem? For instance, this shortcut works just fine:

{
     "key": "ctrl+w",
     "command": "workbench.action.terminal.kill",
     "when": "terminalFocus"
}

The shortcut doesn't work when "command" is set to "extension.vim_ctrl+w" instead, and it's not clear to me why this happens. Perhaps it's related to https://github.com/Microsoft/vscode/issues/44764?

I've been using @parherman's suggestion in the meantime.

The keybindings from @parherman didn't work for me. However, this answer did: https://stackoverflow.com/a/50593160/243157

Fwiw, I've been playing around with this again and apparently ctrl-w now works as expected in terminal. Actually, I got ctrl-w navigation for the explorer working, too. Here's my current setup (my terminal panel is on the right):

    // j/k to move between split terminals, h to move back to the editor
    {
        "key": "ctrl+w j",
        "command": "workbench.action.terminal.focusNextPane",
        "when": "terminalFocus"
    },
    {
        "key": "ctrl+w k",
        "command": "workbench.action.terminal.focusPreviousPane",
        "when": "terminalFocus"
    },
    {
        "key": "ctrl+w h",
        "command": "workbench.action.focusActiveEditorGroup",
        "when": "terminalFocus"
    },

    // j/k to move between "open editors", the explorer tree, and outline;
    // l to move back to the editor
    {
        "key": "ctrl+w k",
        "command": "workbench.files.action.focusOpenEditorsView",
        "when": "filesExplorerFocus"
    },
    {
        "key": "ctrl+w j",
        "command": "workbench.files.action.focusFilesExplorer",
        "when": "openEditorsFocus"
    },
    {
        "key": "ctrl+w l",
        "command": "workbench.action.focusActiveEditorGroup",
        "when": "explorerViewletFocus"
    },
    {
        "key": "ctrl+w j",
        "command": "outline.focus",
        "when": "filesExplorerFocus"
    },
    {
        "key": "ctrl+w k",
        "command": "workbench.files.action.focusFilesExplorer",
        "when": "outlineFocused"
    },
    {
        "key": "ctrl+w l",
        "command": "workbench.action.focusActiveEditorGroup",
        "when": "outlineFocused"
    }

@jesaerys Awesome Job. It works like Charming.

Was this page helpful?
0 / 5 - 0 ratings