almahdi404 / code-django

The ultimate django framework support

Home Page:https://marketplace.visualstudio.com/items?itemName=almahdi.code-django

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using comments with VS Code shorcuts?

ddahan opened this issue · comments

In the extension presentation, I can read:

Zero config , No need to switch to django-html !

However, how auto-comment feature in VS Code is supposed to work , this way?

For example, when I want to comment this block, here is what happens:

image

Of course, I would expect Django template comments like {# ... #} to be used. I don't have this issue with other extension in which django-html format is used rather than normal HTML for Django templates.

Thanks for your help.

I think ctrl+/ should be left for html commenting (<!-- -->)

I am setting ctrl+shift+/ for Django commenting. But currently, it will only support single-line comments ({# #}).
For multiline comments, you can use the comment_block snippet. To do so, select the block you want to comment, type comment_block then hit tab.

Using another language(django-html) disables many vscode html and embedded css, js features. Where you have to create a language server for that language and forward requests to the respective language servers of the embedded languages. Which requires a lot of work and that other extensions don't have. But have a lot of other issues.

Don't forget to support the project if you can.

Closed by (7a6a485)

I am setting ctrl+shift+/ for Django commenting. But currently, it will only support single-line comments ({# #})

I'm not sure how am I supposed to setup this. For example in VS Code, while I know how to configure the shortcuts to toggle comments, where am I supposed to tell: "to comment this block, please use {# ... #}" characters?
Since it's an HTML file, VS Code will always use <!-- ... --> when commenting.

For multiline comments, you can use the comment_block snippet

Please note that using {% comment %} block does not grayed out the commented text. I think this is a bug:

image

In addition, it seems that using this method, there is no way to uncomment a commented block.

I think ctrl+/ should be left for html commenting ()

As a personal opinion, I'd prefer using the same shortcut to comment every filetype, with my IDE intelligent enough to pick the right characters. But I understand if it's complicated.

Don't forget to support the project if you can

I'll be glad to sponsor the project if my problems can be solved in a clean way. As you said, extensions using another language (django-html) have many issues. That's why I had hope using yours. However, commenting is very important as it is constantly used by developers, and I won't be able to use this extension without proper way to do it.

Thanks!

I'm not sure how am I supposed to setup this. For example in VS Code, while I know how to configure the shortcuts to toggle comments, where am I supposed to tell: "to comment this block, please use {# ... #}" characters? Since it's an HTML file, VS Code will always use <!-- ... --> when commenting.

I have added single-line comment feature in the 0.4.0 release.
Now you can find it in the features section.

Please note that using {% comment %} block does not grayed out the commented text. I think this is a bug:

image

It's not greyed out Django documentation.

In addition, it seems that using this method, there is no way to uncomment a commented block.

It requires document indent info, which VSCode does not provide currently. I have opened this issue for that.

As a personal opinion, I'd prefer using the same shortcut to comment every filetype, with my IDE intelligent enough to pick the right characters. But I understand if it's complicated.

It is impossible. Leave ctrl+/ for html commenting and use ctrl+shift+/ for django commenting.

I'll be glad to sponsor the project if my problems can be solved in a clean way. As you said, extensions using another language (django-html) have many issues. That's why I had hope using yours. However, commenting is very important as it is constantly used by developers, and I won't be able to use this extension without proper way to do it.

Thanks!

Hope you have your answers now.

Thanks for your quick answer.

I have added single-line comment feature in the 0.4.0 release.

Thanks, I think it is a good idea. Some feedback : maybe you should not specify the shortcut itself in the documentation for these reasons:

  1. Some people have macs and use cmd rather than ctrl
  2. Some people have no QWERTY keyboard, which means usual shortcuts can differ a little.
  3. It seems (I'm not sure) that if the shortcut is already used by VS Code, another one will be applied.

For me, I found the correct shortcut by looking into the preferences:

image

Hope you have your answers now

Almost :)
When I select all the lines and trigger the shortcut, nothing happens. I think the right behaviour is to comment all the lines at once. For example, if I select this:

image

After running the shortcut, I would expect to have this:

image

(to make the screenshot, I had to comment line one by one).

It will work perfectly in the next release.

Great, I'll patiently watch the new releases then. Thanks for the good work.

check the 0.5.0 release. Hope everything is fine.

I really like the fact the extension detects if it needs a single-line style comment or multi-line style comment.

Besides, as I said, I prefer not using different shortcuts to comment stuff into my project, and since I'm not using html files outside of Django templates, I don't need to be able to comment html files with <!-- .. -->
That's why I tried a trick, which works perfectly:

image

image

Basically, I just set the same shortcut for editor comment action and your extension comment action. Then I disable the editor commenting action for HTML language, sothat your extension is triggered instead.

I guess this could help other people, and could be documented.

Thanks a lot for the great work. I hope you'll continue to maintain this extension and make it famous, as it works better than all the previous I tried.