Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7083575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:11:42+00:00 2026-05-28T07:11:42+00:00

I am using Vim to edit a Java file, but I find the way

  • 0

I am using Vim to edit a Java file, but I find the way Vim formats Java files is very different from Eclipse.

If I select the following code and press =, Vim does not format the code the way I would like. Can anyone help me?

Before Format:

  case RINGTONE_PICKED: {
                            Uri pickedUri = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
                            handleRingtonePicked(pickedUri);
                            break;
                        }
    case PHOTO_PICKED_WITH_DATA: {

        if (mPhotoEditorView != null) {
            final Bitmap photo = data.getParcelableExtra("data");
            mPhotoEditorView.setPhotoBitmap(photo);
        } else {
            // The contact that requested the photo is no longer present.
            // TODO: Show error message
        }

        break;
    }

After Format:

  case RINGTONE_PICKED: {
                            Uri pickedUri = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
                            handleRingtonePicked(pickedUri);
                            break;
                        }
  case PHOTO_PICKED_WITH_DATA: {

                                   if (mPhotoEditorView != null) {
                                       final Bitmap photo = data.getParcelableExtra("data");
                                       mPhotoEditorView.setPhotoBitmap(photo);
                                   } else {
                                       // The contact that requested the photo is no longer present.
                                       // TODO: Show error message
                                   }

                                   break;
                               }

This is what I want:

    case RINGTONE_PICKED: {
        Uri pickedUri = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
        handleRingtonePicked(pickedUri);
        break;
        }
    case PHOTO_PICKED_WITH_DATA: {

        if (mPhotoEditorView != null) {
            final Bitmap photo = data.getParcelableExtra("data");
            mPhotoEditorView.setPhotoBitmap(photo);
        } else {
            // The contact that requested the photo is no longer present.
            // TODO: Show error message
        }

        break;
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T07:11:43+00:00Added an answer on May 28, 2026 at 7:11 am

    Indentation in VIM (and in any other editor or IDE) is carried on by indentation rules coded by someone. There is no guarantee that any two system will follow same indentation practice, since there are different indentation practices around.

    I also use VIM for minor editing Java files, and I’m not aware of any common alternative indentation script for Java, other than the one included in the official distribution. I you’re familiar with VIM scripting you can try to edit the indentation script to your needs. It resides at $VIMRUNTIME/indent/java.vim.

    By the way your example is a little uncommon. Using curly braces for cases of a switch statement is unnecessary. I guess VIM indentation scripts indent blocks by considering the block type and gets confused with this kind of uncommon blocks. Netbeans also get a little confused with this example, it aligns the case blocks in a reasonable way, but the closing curly brace of switch statement is completely out of alignment. That kind of odd behavior will not be so common with default VIM indentation. Actually if you remove the curly braces of the case statements VIM indentation aligns the statements quite well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using vim to edit files that use a programming language where the end
I want to open a file in Vim like in Eclipse using Ctrl +
I am using Vim to edit/compile individual cpp files ( makepgr=g++\ -g\ % )
Right now I am using set autoindent when I edit Yaml files in Vim,
I'm currently using Vim to edit PHP files and would like to implement code
While using Vim (at home and at work), I often find myself doing similar
I've started using Vim to develop Perl scripts and am starting to find it
when I open a file using vim, I'd like vim put the cursor to
Using VIM, it is easy to display line numbers for any given file with:
I have lots of directories with text files written using (g)vim, and I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.