text-editorbbedit

Weird behaviour when uncommenting an indented block of code


I've been using BBEdit (and Textwrangler before) for quite some time, but one thing bugs me - the uncommenting block option seems to eat one space each time you use it. This makes it useless since it breaks the indentation. Also I don't get the difference between "Un/Comment Block" and "Un/Comment Lines", they seem to be doing the same thing, with this weird behaviour as well.

You can easily check this by hitting multiple times Cmd+/, on a block of indented code, e.g:

nodes:
  keypair:
    type: cloudify.openstack.nodes.KeyPair
    properties:
      use_external_resource: true
      resource_id: { get_input: key_pair_name }
      private_key_path: { get_input: private_key_path }

Eventually whole block will get straightened out. Why is that happening? I went through every possible option related to indentation but couldn't eliminate it.

I'm using BBEdit v12.6.

EDIT: Just noticed this happens for YAML code file (.yaml), but not for Python, for example.


Solution

  • For languages which don't support a block-comment syntax (e.g. /*...*/ vs // in C), "Un/Comment Block" and "Un/Comment Lines" are functionally the same.

    There are some ...curiosities involving how spaces are managed after line comment delimiters. If the declared delimiter for the language has trailing spaces, BBEdit tries to figure out what you wanted to do. Some languages care and some don't; and sometimes the outcome has relevance to the language's syntax. It's an area for future study. :-)