Menu

#162 Code completion inserts extra indentation

Minor
closed
nobody
NetBeans (62)
5
2012-02-17
2012-02-03
Jon Cairns
No

I'm using Netbeans 7.0.1 with jVi 1.4.5rc3, and it's changed my life!

One minor problem I'm having is with code completion. When typing something that prompts Netbeans to bring up a list of possible code snippets, after selecting one the code is inserted but also indented one indentation further than the rest of the code. This seems to happen when using either tabs or spaces as the indentation character.

This wasn't happening before I started using the jVi plugin.

As I say, it's not a critical problem, as it just needs to be shifted back, but I love the speed of coding with Vi(m), and anything to make things slightly quicker is a win!

Thanks for all your work.

Discussion

  • Ernie Rael

    Ernie Rael - 2012-02-03

    jVi re-programs the NB settings for shiftwidth, expandtabs and tabstop; you can read some about it at http://jvi.sourceforge.net/?ReadmeNetBeans.html under "Options". If you have files with different settings, then you can use modeline in the file.

    Let me know if this doesn't resolve the issue.

    I've seen what you're talking about when the settings don't match the current formatting of the file.

    There are some cases, particularly "insert code", where NB doesn't follow the settings.

     
  • Ernie Rael

    Ernie Rael - 2012-02-03
    • status: open --> pending
     
  • Jon Cairns

    Jon Cairns - 2012-02-16

    Thanks for the reply. I spent a bit of time looking at the options that you talked about, and played around with different settings. I noticed that I had "Use the platform's TAB handling" enabled in the Platform settings, so I disabled that (I assume that's the best thing to do?). However, I couldn't change the behaviour of an extra indentation being added after selecting an autocomplete entry.

    Basically, what I want to achieve is:

    - Tabs, not spaces
    - One tab is represented as 8 spaces width

    Also, I should mention that all our code follows the rule of tabs not spaces. The settings I chosen in jVi are:

    - Don't use the platform's TAB handling
    - Expand tab: false
    - Shiftwidth: 8
    - Softtabstop: 0
    - Tabstop: 8

    It seems like changing any of the last four settings doesn't actually seem to change the behaviour at all, which is strange. I'm pretty much positive that I'm doing something wrong - any idea what it could be?

    Thanks for your help.

     
  • Ernie Rael

    Ernie Rael - 2012-02-16

    Maybe if you attached a small java file, with exact steps to reproduce. You've already provided the jVi settings.

    The various settings in
    Menu>Tools>Options>Editor>Formatting
    in all the Java Categories might have something to do with it as well.

    Don't use the platform's TAB handling is usually the right thing, but it doesn't affect what happens during code completion.

     
  • Jon Cairns

    Jon Cairns - 2012-02-17

    I've discovered what it is!

    While writing an example class to show what was happening (PHP, not Java), I found that there was a setting in the Netbeans PHP option, "Continuation Indentation". This was set to 8, but setting it to 0 fixed the problem. It doesn't seem to have had any other effects.

    Weirdly, I found it was only indenting when autocompleting methods, but not properties, variables or class names.

    Sorry for raising it as a jVi issue, but thanks a lot for all your help!

     
  • Ernie Rael

    Ernie Rael - 2012-02-17
    • status: pending --> closed
     
  • Ernie Rael

    Ernie Rael - 2012-02-17

    > I've discovered what it is!

    Cool. Glad you've got it working the way you want.

    I wonder if the PHP folks would like to hear about this.

     

Log in to post a comment.