Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 547
mattf Avatar asked Oct 26 '25 20:10

mattf


1 Answers

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.

like image 149
herrbischoff Avatar answered Oct 28 '25 22:10

herrbischoff