Meino Christian Cramer wrote:
Hi,Suppose the following piece of C-code: /* * This is a comment* It does say nothing []The "[]" marks the current cursor position. When hitting <RET> in this situation, Mr. Cursor will jump right below the prevous lines "*" adding another "* " to continue the comment -- not knowing, that the programmer has finished the comment already and wants to start programming "real code" ;) . Would it possible (or isit already possible) to convince vim from acting as follows: Rule 1: When Mr. Cursor is positioned in a comment line of more than only a '*' and <RET> is entered, continue the comment with the next '*' Rule 2: When Mr. Cursor is positioned in a comment line containing only a '*' and <RET> is entered close the lonely '*'of the current line with a '/' and jump into the next line without adding anothe '*' Would make hacking code a little faster... Hopeing not to have invented the wheel a third time... Keep hacking! mcc
With the default setting of 'comments', which includes "ex:*/", typing the / after the middle part of the three-piece comment has been inserted, will end the three-part comment. Thus in the example you give, hit Enter, (Vim inserts * on a new line), hit slash (Vim suppresses the space between * and /), hit Enter again, and there won't be any comment leader on the next line.
Note: It is quite legitimate to have one long three-piece comment with blank lines (well, lines with only the *) in the middle, separating paragraphs.
See ":help format-comments" which is 111 lines long in my version of change.txt (for Vim 7.0, last change 2006 May 05).
Best regards, Tony.
