Search code examples
neovimnerdcommenter

How can I add space between code and comment?


I'm using nerdcommenter alongside neovim, and every time I comment out a block of code with <leader>cc, the code isn't really spaced out:

fn main() {
    //println!("Hello, world!");
}

I want to get an output of something like this:

fn main() {
    // println!("Hello, world!");
}

Is there a command or configuration that I'm missing out on? (I haven't configured nerdcommenter at all in my vimrc)


Solution

  • See the plugin docs : use g:NERDSpaceDelims configuration option

    " Add spaces after comment delimiters by default
    let g:NERDSpaceDelims = 1
    

    Or for Neovim with Lua configuration :

    vim.g.NERDSpaceDelims = 1