[TxMt] Best way to implement vim-like block comments?

Corey O'Connor coreyoconnor at gmail.com
Sat Feb 25 10:28:00 UTC 2006


One thing I liked about vim was the continuation of the "*" down the
same column for each line in a block comment. So something entered
like:
(* Hello!
Blah

would be formated to:
(* Hello!
 * Blah

I implemented this in the O'Caml language by changing the block
comment language rule to:
{	name = 'comment.block.ocaml';
			begin = '\((\*.*)\)?$';
			end = '\*\)';
			beginCaptures = { 1 = { name = 'comment.block.ocaml.begin'; }; };
		},

And adding two snippets for the return key: One for the scope
comment.block.ocaml.begin that would return, space in, and add a "* ".
One for comment.block.ocaml that would only return and add a "* ".

Xefore I charge off and add this for C, is this the best way to
implement this feature? Or am I missing an easier way? I've attached
the two snippets and language syntax for O'Caml if anybody would like
to try ti.

--
-Corey O'Connor
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vim like OCaml block comments.zip
Type: application/zip
Size: 2660 bytes
Desc: not available
URL: <http://lists.macromates.com/textmate/attachments/20060225/eba39322/attachment.zip>


More information about the textmate mailing list