VSCodeVim / Vim

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

vim dont work if is not buffer open #8700

Open TheElegantCoding opened 11 months ago

TheElegantCoding commented 11 months ago

i have some keymaps to show projects and do more stuff, but vim only works if i have a buffer or tab open, if not any command is not executed, even if i am in a project or a folder

"vim.leader": "<space>",
  "vim.foldfix": true,
  "vim.hlsearch": true,
  "vim.useSystemClipboard": true,
  "vim.highlightedyank.enable": true,
  "vim.highlightedyank.color": "rgba(28, 78, 216, 0.5)",
  "vim.normalModeKeyBindings": [
    {
      "before": [
        "leader",
        "p"
      ],
      "commands": [
        "projectManager.listGitProjects#sideBarGit"
      ]
    },
    {
      "before": [
        "leader",
        "a"
      ],
      "commands": [
        "workbench.action.toggleActivityBarVisibility",
      ]
    },
    {
      "before": [
        "leader",
        "w"
      ],
      "commands": [
        ":w!"
      ]
    },
    {
      "before": [
        "leader",
        "q"
      ],
      "commands": [
        ":q!"
      ]
    },
    {
      "before": [
        "leader",
        "x"
      ],
      "commands": [
        ":x!"
      ]
    },
    {
      "before": [
        "<c-a>"
      ],
      "after": [
        "g",
        "g",
        "V",
        "G"
      ]
    },
    {
      "before": [
        "<S-h>"
      ],
      "commands": [
        ":bprevious"
      ]
    },
    {
      "before": [
        "<S-l>"
      ],
      "commands": [
        ":bnext"
      ]
    },
    {
      "before": [
        "leader",
        "v"
      ],
      "commands": [
        ":vsplit"
      ]
    },
    {
      "before": [
        "leader",
        "s"
      ],
      "commands": [
        ":split"
      ]
    },
    {
      "before": [
        "leader",
        "h"
      ],
      "commands": [
        "workbench.action.focusLeftGroup"
      ]
    },
    {
      "before": [
        "leader",
        "j"
      ],
      "commands": [
        "workbench.action.focusBelowGroup"
      ]
    },
    {
      "before": [
        "leader",
        "k"
      ],
      "commands": [
        "workbench.action.focusAboveGroup"
      ]
    },
    {
      "before": [
        "leader",
        "l"
      ],
      "commands": [
        "workbench.action.focusRightGroup"
      ]
    },
    {
      "before": [
        "leader",
        "f"
      ],
      "commands": [
        "workbench.action.quickOpen"
      ]
    },
    {
      "before": [
        "z",
        "r"
      ],
      "commands": [
        "editor.foldAll"
      ]
    },
    {
      "before": [
        "z",
        "m"
      ],
      "commands": [
        "editor.unfoldAll"
      ]
    },
    {
      "before": [
        "leader",
        "c"
      ],
      "commands": [
        "editor.action.commentLine"
      ]
    },
    {
      "before": [
        "g",
        "h"
      ],
      "after": [
        "g",
        "^"
      ]
    },
    {
      "before": [
        "g",
        "l"
      ],
      "after": [
        "g",
        "$"
      ]
    },
  ],
  "vim.insertModeKeyBindings": [
    {
      "before": [
        "k",
        "j"
      ],
      "after": [
        "<Esc>",
        "l"
      ]
    }
  ],

Here you can se i have a buffer open and f that open files works image

But if i close all buffer like this i cant use any vim command image

The vim extension is active but i cant even type ":" for put a command image

lungarella-raffaele commented 4 months ago

I am having the same problem. Did you find a way to fix this?

TheElegantCoding commented 4 months ago

not yet, same problem

tanishqmanuja commented 3 months ago

I have to duplicate command like this which I want to work without buffer open

settings.json

"vim.normalModeKeyBindingsNonRecursive": [
    {
      "before": ["<leader>", "p", "f"],
      "commands": ["workbench.action.quickOpen"]
    }
  ]

keybindings.json

 [
   {
     "key": "space p f",
     "command": "workbench.action.quickOpen",
     "when": "vim.mode == 'Normal' && !(editorTextFocus || inputFocus)"
   }
]
TheElegantCoding commented 3 months ago

Still this require an extra key binding and it's duplicate, I don't think this is a good solution

tanishqmanuja commented 3 months ago

Yup, but nobody said it was a solution, it's a work around.