Savanaly
Savanaly

Reputation: 347

Vim auto generating undesired JS comment blocks

For .js files if I type

/**<Enter>

Vim creates

/**
 * 

This is annoying, I don't want the asterisk on the second line added (it's also added to the start of any additional lines). It's probably being generated by one of the plugins I have installed (this ended up being not the case, ignore what I have below this) (I installed all with Pathogen), so I followed this process:

  1. Uninstall a specific plugin (by moving its folder out of ~/vimfiles/bundle - let me know if this isn't the right way to uninstall Pathogen plugins)
  2. Check in a .js file to see if the behavior was fixed (it never was)
  3. Reinstall the specific plugin since apparently that wasn't the problem

I repeated that for all plugins (listed below) and couldn't make the behavior go away. Any ideas?

My plugins, they should all be fairly popular, uncontroversial choices:

Upvotes: 1

Views: 222

Answers (2)

benjifisher
benjifisher

Reputation: 5122

This behavior is specified by the 'comments' option. See where it was set with

:verbose set comments?

Probably it is set in the default ftplugin for javascript. Decide on a value you like, such as :set comments= or :set comments=://. Then you can set this for future javascript files using an :autocommand as in @brettanomyces's answer or by using one of the methods described in :help ftplugin-overrule. I recommend the third option described there.

Upvotes: 1

Brett Y
Brett Y

Reputation: 7688

Try

:set formatoptions-=r

or add the following to your .vimrc

autocmd FileType * setlocal formatoptions-=r 

formatoption 'r' automatically inserts the current comment leader after hitting <enter> in Insert mode.

See:

:h formatoptions
:h fo-table

Upvotes: 3

Related Questions