On May 12, 4:05 am, Dennis Benzinger <[email protected]> wrote:
> Is there a script or does anyone have a ready to use regex to turn a
> switch statement into a series of if else statements (Java/C)?
>
> For example:
>
> switch (shoeSize) {
> case 8:
> foo();
>
> case 9:
> bar();
>
> default:
> baz();
>
> }
>
> into
>
> if (shoeSize == 8) {
> foo();
>
> } else if (shoeSize == 9) {
> bar();
> } else {
> baz();
> }
>
> It doesn't need to handle case blocks with or without break statements
> correctly.
Well, without the break statements, the two code snippets you give are
not at all equivalent.
This is something I don't need to do very often, so when I encounter
it, I usually just record a macro on the first case statement and run
it on the rest.
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---