-1

How can I toggle comments on blade.php extension files.

Blade is a Laravel specific file which uses {{-- --}} to comment out.

I installed Nerdcommenter but, don't know how to modify it to work with blade files due to the lack of Vim knowledge

Now, when I comment out the plugin uses

<!-- -->

Does anyone know how to set the thing up or recommend me other plugins?

shigg
  • 792
  • 1
  • 8
  • 24

1 Answers1

1

nerdcommenter already have the comment style you mention, but you need to be using the filetype laravel for it to work properly.

Try issuing :set ft=laravel before using nerdcommenter again.

To make this work everytime you edit a blade file, you can include the following line in your vimrc:

autocmd BufRead,BufNewFile *.blade.php set filetype=laravel

You probably also need to ensure that you have filetype indent plugin on in your vimrc.

rgoliveira
  • 908
  • 10
  • 16
  • Thanks for the comment sir.I added it to my vimrc file.But, it won't work – shigg Aug 26 '16 at 04:51
  • You have to use the command after you open the file. Vim will try to guess the filetype as you open a file, and since the extension is `php`, it'll default to the `php` filetype. – rgoliveira Aug 26 '16 at 04:54
  • After I open the blade file and type the command in vim.It worked thx.But,after I close Vim it no longer works.How can I make it permanent?Thank you for helping me really – shigg Aug 26 '16 at 06:30
  • What's the name of your files like? Do they end with `.blade.php`? – rgoliveira Aug 26 '16 at 06:48
  • Yes.it's like {filename}.blade.php – shigg Aug 26 '16 at 06:59
  • Try putting this in your `vimrc`: `autocmd BufRead,BufNewFile *.blade.php set filetype=laravel` – rgoliveira Aug 26 '16 at 07:02
  • Thanks @rgolivaira I added autocmd BufRead,BufNewFile *.blade.php set filetype=laravel.But no luck – shigg Aug 26 '16 at 07:13
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/121900/discussion-between-rgoliveira-and-shigg). – rgoliveira Aug 26 '16 at 07:35
  • Looks like filetype needs to be "blade", this way it works with both vim-blade and nerdcommenter – michaeltintiuc Nov 24 '17 at 22:18