How to delete all content in file in vscode vim?

Viewed 511

In normal .vimrc I have following mapping:

:nnoremap <leader>s G$vggx

To delete everything from bottom to up. I would like to something similar in VS Code vim plugin (in settings.json):

"vim.normalModeKeyBindings": [
 {
  "before" : ["leader", "s"],
  "after" : ["G$vggx"]
 }
],

Of course does nothing, but having type it manually, then it works. So how to make the vs extension accept these key sequence?

1 Answers

There are two solutions that come to mind.

Using the built-in vim-textobj-entire

The text object ae represents the entire content of a buffer in Vim for VSCode. You can use this text object in combination with the d command.

dae

Adding your own mapping

Add the following to your settings.json file in VSCode.

    "vim.normalModeKeyBindingsNonRecursive": [
        {
        "before": ["<leader>", "s"],
        "after": ["g", "g", "d", "G"]
        }
     ]

Then you can type <leader>-s to delete the contents of your current editor.

Please note that it is not necessary to visual select what you want to delete; therefore I used ggdG.

Related