Search code examples
vimvim-plugin

Vim keeps putting in "*" on new lines


So I keep running into this problem when I'm working in CSS.

I'll enter in "*" to reset the HTML, but I'll hit enter and I'll end up getting something that looks like this:

* {
    *
    *}

I have a plugin that automatically completes my brackets but I know it's not that causing it.

Is there any setting I can change that will make that stop?


Solution

  • You can disable that feature with this command:

    :set formatoptions-=r
    

    See :help fo-table.

    NOTE: this actually changes Vim's behaviour when writing comments, which may or may not be an acceptable trade-off.

    If you want that setting to be applied automatically every time you edit a css file you can add these line to your vimrc:

    augroup css
        autocmd!
        autocmd FileType css set formatoptions-=r
    augroup END
    

    Alternatively, you can put that line:

    set formatoptions-=r
    

    in that file:

    ~/.vim/after/ftplugin/css.vim