Vscode-ruby: (Feature Request) Better .erb support for comments in vscode using shortcut

Created on 24 Aug 2018  路  8Comments  路  Source: rubyide/vscode-ruby

Your environment

  • vscode-ruby version:
  • Ruby version: ruby 2.5.1
  • Ruby version manager (if any): rbenv
  • VS Code version: 1.25.1
  • Operating System: macOS 10.13.6 High Sierra
  • Using language server?

Hello :)

I was hoping for better .erb support in vs-code.
Specifically, commenting out .erb and .html.erb files using shortcut (command + /) would be great. Currently, I can comment out other files just fine using shortcuts but .erb and .html.erb files does not support command + / for some reason. Please correct me if I am wrong and it already works :)

Thanks,
Dave

stale

Most helpful comment

Would also love for ctrl + / to insert HTML comments by default not ERB comment tags. The ERB comment tags don't work when trying to comment out any block of code containing embedded rub, making them not very helpful.

Is anyone aware of an extension or way to change this behavior in the meantime?

All 8 comments

What vscode-ruby version are you on?

Regardless, this does not seem to be a problem with this extension. VS Code has always been a little funky when dealing with .erb files (HAML ftw!). I will try to reproduce later, but like I said this is not a problem with this extension imo.

I also got an issue with a comment out function in .html.erb files using your extension. In my case cmd + / works but it messes up file syntax. When I invoke cmd + / in line: <p><%= t'.body_part_two_html' %></p> it becomes <%# <p><%= t'.body_part_two_html' %></p> %>. In Atom it works as expected so I got standard html comment syntax <!-- <p><%= t'.body_part_two_html' %></p> -->. I would love to use HAML but project I'm in is relaying on .html.erb and still it's offical rails format. It may be an issue with VS Code itself as you said below but it's sad that they cannot fix such small issue (it occurs everysince I started using VS Code months ago).

Do you have any erb related extensions turned on?

Enabling this (extension)[https://github.com/VenseChang/vscode-rails] created the behavior you were looking for.

@andrewmcodes indeed it works as I was expecting too. Thanks for sharing this link.

Would it be possible to add an option to this extension so that we can choose what html.erb block comments use? Currently, this extension inserts <%# ... %> which I almost never find useful, instead preferring real html comments.

The comments are specified in the language grammar. I'm not aware of VSCode APIs that allow you to specify grammar specific overrides. This may be solvable via the autocompletion APIs but I don't know if those can be tied into the command + / stuff without a hotkey remap.

Would also love for ctrl + / to insert HTML comments by default not ERB comment tags. The ERB comment tags don't work when trying to comment out any block of code containing embedded rub, making them not very helpful.

Is anyone aware of an extension or way to change this behavior in the meantime?

This issue has not had activity for 30 days. It will be automatically closed in 7 days.

Was this page helpful?
0 / 5 - 0 ratings