Ticket #1547 (closed cage: done)

Opened 5 years ago

Last modified 4 years ago

Mass-update vim modelines

Reported by: petdance Owned by: petdance
Priority: normal Milestone:
Component: none Version: 2.2.0
Severity: medium Keywords:
Cc: Language:
Patch status: Platform:

Description

We need to have an updated vim modeline that sets the cindent options that match our coding standards. Specifically, the default vim options don't support the way we do switch/case labels, with the 2-space indent. Reindenting a block of code with a switch in it destroys the indents.

The cindent options are detailed here:  http://vimdoc.sourceforge.net/htmldoc/indent.html#cinoptions-values

Then, since we need to update that everywhere, we need a tool to mass-update vim modelines everywhere in the project because you just KNOW we'll have to do it again anyway.

Change History

Changed 5 years ago by bacek

Can we change coding standard to 4 space indent instead?

Changed 5 years ago by petdance

In my mind it's not either-or.

That said, I would love to not have the 2-space outdent on labels.

Changed 4 years ago by coke

If you can summarize what the new vim line should be, someone can update it.

Getting the tool sounds like a good thing, but it's one more thing we have to maintain, so I'm not convinced.

The easiest way to get this going is to change the tests for the codas. (And wouldn't it be nice if we could just declare this in a project file somehow so we didn't need to touch every single file in the repo.)

Changed 4 years ago by plobsing

  • status changed from new to closed
  • resolution set to done

I've modified the modelines in master appropriately.

The modeline setting is cinoptions='\:2=2' (indent labels by 2, indent statements following labels by 2).

We already have a tool for getting all the C files - Parrot::Distribution.pm. To modify modelines en mass:

  1. get paths to c language files from Parrot::Distribution
  2. check that each file has exactly one match for your "from" regex
  3. search and replace

Example:

perl -Mlib=lib -MParrot::Distribution -E 'say $_->path for Parrot::Distribution->new->get_c_language_files' | xargs sed -i "s/vim:\(.*\):$/vim:\1 cinoptions='\\\\:2=2' :/"
Note: See TracTickets for help on using tickets.