How to Execute Vim Command to Delete All Empty Lines in VSCode and VSCodeVim?

48 Views Asked by At

I'm using VSCode and the VSCodeVim plugin. I'm attempting to create a key mapping to delete all empty lines in a file, but I'm encountering issues.

Here's the code snippet that I've added to my VSCode configuration:

{
  "before": ["<Leader>", "q"],
  "after": [],
  "commands": [
    {
      "command": ":s/^\\s*\\n//g<Enter>",
      "args": []
    }
  ]
}

When I use the above configuration, I get a "trailing spaces" error. If I remove the Enter from the command, it gets posted to the command line but doesn't get executed. Pressing colon afterwards deletes the command. I have also not been able to switch focus over to the command line without deleting the current contents.

0

There are 0 best solutions below