Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

comments and multiline comments #198

Closed
MarkusLohmayer opened this issue Jun 5, 2020 · 3 comments
Closed

comments and multiline comments #198

MarkusLohmayer opened this issue Jun 5, 2020 · 3 comments

Comments

@MarkusLohmayer
Copy link

Hi everyone,
I have a short question regarding comments in Julia files.
Usually I use https://github.com/tpope/vim-commentary for (un)commenting.
For some reason, julia-vim is configured in a way that it will insert #= ... =# on every line.
IHMO this is not ideal and feels too heavy.

Thanks to some helpful tips I received in #vim channel on the Julia Slack,
I could change the behavior.
The following two solutions were presented:

  1. Putting let b:commentary_format = '# %s' in ftplugin/julia.vim
  2. Putting autocmd FileType julia setlocal commentstring=#\ %s in the vimrc.

So for me the problem is basically solved as I now just get the # ... at the beginning.

But some questions remain:

  1. Shouldn't this be the default behavior, so others also get the comment syntax they presumably expect?
  2. What was the reason to specify the multi-line comment syntax for comments in julia-vim in the first place?

Thank you very much!
Markus

@kdheepak
Copy link

kdheepak commented Jun 5, 2020

Thanks for opening the issue. I also agree that the default should be just a single # before every line.

I think this is the only line that needs to be changed.

setlocal commentstring=#=%s=#

@carlobaldassi
Copy link
Contributor

carlobaldassi commented Jun 6, 2020

Answers:

Shouldn't this be the default behavior, so others also get the comment syntax they presumably expect?

It's hard to predict what people would expect...

What was the reason to specify the multi-line comment syntax for comments in julia-vim in the first place?

Well, the reason is that they exist, in a sense. Also, another reason is that although it's possible in principle to specify different types of comments in comments, in practice it doesn't work well at all. So as a sort of fallback the two kind of comments are specified in those two different variables.

As for commenter plugins. vim-commentary is quite limited, I would say. But then again its README tells you exactly what you ought to do to use it with your favourite file type. Other commenting plugins such as tcomment work well because it uses comments. I'm using a small plugin that I wrote myself a long time ago (this one) which uses both comments and commentstring, and it can use the #=%s=# form with visual selections, in case you want to comment out a piece of a line, for example (but I still have to force b:smartcomment_force_linemode=1 in my vimrc).

So I don't think changing commentstring is correct.

I guess the best solution is just to add some plugin-specific tweaks in ftplugin/julia.vim.

@MarkusLohmayer
Copy link
Author

Thank you very much!

This was referenced Feb 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants