mattf
mattf

Reputation: 95

How to delete empty lines on visual studio code with the vim mode

I've been trying to delete many empty lines from a huge file. On other editors with vim, or vim itself, I could just do:

:%s/\n\n/\n/g

But neither if I use \r or \t it doesn't work. Seems like some vim features are missing on the editor. Is there any configuration to make that work or another way to do that?

Upvotes: 4

Views: 2050

Answers (1)

herrbischoff
herrbischoff

Reputation: 3326

To have advanced Vim functionality work within VScode, you can leverage its Neovim integration.

First, you'll have to install Neovim. For instructions, check out: https://github.com/neovim/neovim/wiki/Installing-Neovim

Then, adjust the following settings in your user configuration:

// Use neovim on backend. (only works for Ex commands right now). You should restart VScode after enable/disabling this for the changes to take effect. NOTE: Neovim must be installed (v0.2.0) and neovimPath must be set the executable in order for this setting to work. Otherwise, vscodevim will crash.
  "vim.enableNeovim": true,

// Path to run neovim executable. For example, /usr/bin/nvim, or  C:\Program Files\Neovim\bin\nvim.exe
  "vim.neovimPath": "nvim",

Restart VScode. Now you can use Vim Ex commands, since the commands are sent to a headless Neovim instance that's running in the background. You can even use installed Vim plugin functions to a certain degree.

Upvotes: 5

Related Questions