Closed (fixed)
Project:
Vim Plugin For Drupal
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
11 Oct 2011 at 00:50 UTC
Updated:
12 Nov 2011 at 10:40 UTC
Jump to comment: Most recent file
The attached patch sets the 'textwidth' and 'comments' options, and modifies the 'formatoptions' option, to improve formatting of comments in vim, especially documentation blocks. I explain these settings in the comments in the vimrc file and in this comment. The 80-character limit for comments is recommended here.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | comment-format-1305564-6.patch | 2.06 KB | benjifisher |
| #2 | comment-format-1305564-2.patch | 1.12 KB | benjifisher |
| vimrc-comment-format.patch | 1.04 KB | benjifisher |
Comments
Comment #1
benjifisherI forgot to mark it "needs review."
Comment #2
benjifisherI re-rolled the patch. It now applies to
ftplugin/php_drupal.vim.Comment #3
Niklas Fiekas commentedAwesome! I had something that had the same behaviour in an old copy-paste created .vimrc - then I lost it and I've always wanted it back ;)
One thing that could be better, though it never happens in real life: // aneightycharacterlongwordthathasnospaces - shouldn't be split on to multiple lines.
One other thing is, that
/**is easily closed by*/<enter>, while// foo<enter>starts a new//which is useful on the one hand, but annoying if you don't need it. Could// foo<enter><backspace>delete the whole new//or how is it supossed to be used?Comment #4
benjifisherNiklas:
Thanks for testing. If we only allowed people who are experts on vim script to review our changes, it would slow us down a lot. If there are no further comments in the next few days, I will add something to the documentation and commit a patch.
I am not sure about your first comment. I tried
and the line did not break. Is that good or bad?
Closing comments is even easier than you say. After starting a comment with
/**the*will be entered automatically on a new line; you only have to type the/to close the comment. I mention this in the comments offtplugin/php_drupal.vim.A Google search for "vim remove comment leader" turns up a suggestion I made almost exactly 10 years ago on the vim users' mailing list: use
<C-U>to delete the inserted comment leader. You could make a key mapping and function, but it might be easier to re-train your fingers. After all, your little finger is never far from the control key, right? http://tech.groups.yahoo.com/group/vim/message/21587Another possibility for the
commentsoption is the C default,set comments=s1:/*,mb:*,ex:*/,://As far as I can tell, this behaves identically for doc blocks, but it also recognizes comments that start with
/*instead of/**. I am inclined to leave the setting as we have it now, to discourage commenting that does not follow Drupal coding standards. I feel kind of like Big Brother, though.Comment #5
Niklas Fiekas commentedThere is no wrong line break and thats awesome - the line break i saw came from a too small terminal :D
<C-U>works very well, too. I keep getting faster there.Only allowing /** to start docblocks is ok, I think. It's not even Drupal only.
If there are no other technical issues I think it's ready to be comitted. It's a really useful feaure - thank you for creating the patch and explaining everything.
Comment #6
benjifisherI have committed the attached patch. It is the same as in #2 plus a few lines added to
doc/drupal.txt.Comment #7
Niklas Fiekas commentedbenjifisher++ ;)