Author Topic: auto indent problems  (Read 3453 times)

Chris17404

  • Junior Community Member
  • Posts: 3
  • Hero Points: 0
auto indent problems
« on: September 16, 2009, 08:35:53 pm »
Hi all,

I recently re-installed SlickEdit 10.0 afetr my previous development machine crashed.  I am reconfiguring SlickEdit back to my liking.  One thing I can 't seem to do is set it up such that when I hit ENTER as I am adding parameters to a function, it won't auto indent to the level of the previous parameter.  I've tried enabling "Use continuation indent on function parameters", but doesn't seem to work.

Also, if I simply hit ENTER on an empty line of code, it used to automatically indent the new line to the level of the live above.  It no longer does that.  What am I missing?

The only thing that does seem to still work is when I hit ENTER on an existing line of code, the new line in this case is auto-indented to the same level.

Thanks for any help you can provide!

Chris

Chris17404

  • Junior Community Member
  • Posts: 3
  • Hero Points: 0
Re: auto indent problems
« Reply #1 on: September 17, 2009, 06:34:24 pm »
Anyone got a clue?   :)

ScottW, VP of Dev

  • Senior Community Member
  • Posts: 1471
  • Hero Points: 64
Re: auto indent problems
« Reply #2 on: September 17, 2009, 07:51:25 pm »
First, let's make sure you have Syntax Indent on. Select Tools > Options > File Extension Setup, Indent tab. Make sure Indent style is set to "Syntax indent". This is likely the issue causing both problems.

If Syntax indent is off, hitting enter will always put the cursor in column 1. If it is on, then you can use the "Use continuation indent on function parameters" to control where the cursor goes in argument lists.

When checked you get this:
Code: [Select]
Rectangle::Rectangle(const Point& topLeft,
    const Point& bottomRight){

When unchecked you get this:
Code: [Select]
Rectangle::Rectangle(const Point& topLeft,
                     const Point& bottomRight){



Are you using a default configuration? What you are looking for should be the default behavior in a clean config? What language are you coding in?

Chris17404

  • Junior Community Member
  • Posts: 3
  • Hero Points: 0
Re: auto indent problems
« Reply #3 on: September 18, 2009, 06:55:09 pm »
Hello Scott,

Thanks for your post.  I was able to get it running the way I want.  I code in both C++ and Java.  I had originally been using Syntax Indent in my Java files, which always simply idents 4 spaces (by default).  But in C++, it correctly indents to the position of the line above.  So, I simply made the java file extension setup refer to the c setup, and now it works the way I want for both types of source files.  I have Syntax Indent enable and have "use continue..." disabled.  Thanks for the help.

Chris

ScottW, VP of Dev

  • Senior Community Member
  • Posts: 1471
  • Hero Points: 64
Re: auto indent problems
« Reply #4 on: September 21, 2009, 02:16:58 pm »
Glad to be of service! I'm a little confused about the behavior you are seeing in Java. Under my testing, both languages appear to behave the same with regards to indenting. When I hit enter on a line, blank or otherwise, the new line is automatically indented to the location of the last non-blank line (with an extra indent level added if the previous line begins a block). If I hit tab on the new line, the syntax indent amount is used to determine how far to indent.

Can you post a small code sample in Java and describe the behavior you're seeing. Are you saying that when you hit Enter, SlickEdit indents the new line 4 spaces, putting the cursor in column 4?

Here's what I'm seeing?

Sample code, badly formatted
Code: [Select]
            if (docEl == null) {
                        System.out.println("No document element.");

                return -1;
            }

Sample code, comments show where each new line is indented.
Code: [Select]
            if (docEl == null) {
                // indented to here
                        System.out.println("No document element.");
                        // indented to here
                        // indented to here

                return -1;
                // indented to here
            }

I can't tell you what you're going to lose by associating java files with the C/C++ mode, but it seems like harsh way to solve this problem. Did you start with a clean install of SlickEdit and a clean config? I'm confused where these behaviors are coming from.