Author Topic: 4 tabs instead of 1 when tab inserted  (Read 4358 times)

Paul9876

  • Junior Community Member
  • Posts: 9
  • Hero Points: 0
4 tabs instead of 1 when tab inserted
« on: April 13, 2016, 09:46:36 pm »
Hi,

I'm using slickedit pro 2015 (v20.0.1.3 64-bit) on linux. I'm new to slickedit and I've searched for an answer, but nothing seems to work.

I have a C file that has tabs in it. When I open the file in slickedit and hit tab then the cursor goes 4 tabs. If I save the file and look at it with vi, then I can delete 3 tabs and the line will be in the correct place.

I'm sure there is some option that is controlling this, but I can't seem to find it. I have Tools->Options->Languages->All Languages->Formatting Indent with tabs set, Syntax indent is set to 4, and Tabs is set to +4. I have tried changing these settings and nothing seems to happen.

Additionally I have looked at Tools->Options->Languages->Application Languages->C/C++/Formatting, clicked Edit. The options are set as follows:
'Indent with' 'Tabs'
'Syntax indent' '4'
'Tab stops' '+4'
'Line continuation indent' '4'

What am I missing? Nothing seems to change the behavior such that hitting tab inserts 1 tab stop.

Paul

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1397
  • Hero Points: 128
Re: 4 tabs instead of 1 when tab inserted
« Reply #1 on: April 14, 2016, 01:41:48 pm »
That sounds pretty strange.  Do you have adaptive formatting enabled? (You can look in the Document menu and see if the Adaptive Formatting entry at the bottom is checked).  If so, does turning it off help? 

The only way I know of for that to happen is if the tab setting for that buffer has been set to something lower than the +4 you have in your configuration, and as far as I know adapative formatting is the only automatic feature that can silently change the tab setting for a buffer. (barring some bug we don't know about).

Also, if you select View -> Special Chars, it shows spaces and tabs in the buffer you have open.  Spaces will be little dots, tabs are horizontal lines with vertical ticks marking off their width.  That would let you see if it's putting in lots of little tabs as you type, rather than the +4 spaced tabs, without having to switch out to vi.

Paul9876

  • Junior Community Member
  • Posts: 9
  • Hero Points: 0
Re: 4 tabs instead of 1 when tab inserted
« Reply #2 on: April 14, 2016, 05:38:27 pm »
Patrick,

Adaptive formatting is off, but I have turned it on and off during my initial testing so maybe something got messed up there. I also tried setting the +4 to +1 at some point to try to get rid of it and I think I got a message about it messing up adaptive formatting or something. Maybe that hosed things up? To add to the weirdness, if I turn off 'Indent with tabs' in the Documents settings, I get 4 spaces. I would have assumed because of the weird 4 tabs things that I would get 16 spaces. Does that give any clues?

I have Show special characters turned on, that's how I can tell that 4 tabs have been inserted instead of 1, but I was using vi to double check that it was 4 tabs.

Don't know if this helps, but I'm using a trial license and I have opened the file as not part of a project. I don't know if there is any help there.

Is there some way to reset everything to default again? Could I blow the install away (keeping the license file) and reinstall with the trial license I have to get back to a default config?

Paul

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1397
  • Hero Points: 128
Re: 4 tabs instead of 1 when tab inserted
« Reply #3 on: April 14, 2016, 06:07:58 pm »
Well, that does seem to indicate the tab setting is set to 1, but only for that document.

You can start with a clean configuration by removing the .slickedit directory in your home directory - that just contains user configuration, so it can always be removed without having to un-install.  Hopefully this isn't necessary.

So one clarification:  when you go to Tools->Options->Languages->Application Languages->C/C++/Formatting and look at the indent settings there, those are the settings for the language.  You open a C file for the first time, these are the settings that are used.

But some of the SlickEdit properties (like tab width and syntax indent) can be changed for a particular file.  Adaptive formatting changes these per file settings, and these file specific changes are remembered, so the next time you open that file, the changed settings for that document will still be there, even if you've disabled Adaptive Formatting in the meantime. 

The nuclear way to 'forget' these particular per-file settings is to exit SlickEdit, remove the ~/.slickedit/20.0.1/vrestore.slk, and then restart SlickEdit.  In this case, you can probably go to Document -> Tabs, and set it to +4, and that would take care of it for that file.


Paul9876

  • Junior Community Member
  • Posts: 9
  • Hero Points: 0
Re: 4 tabs instead of 1 when tab inserted
« Reply #4 on: April 15, 2016, 04:41:52 pm »
Patrick,

I exited slickedit, removed the ~/.slickedit/20.0.1/vrestore.slk file, restarted slickedit, and the problem still persisted. I then quit slickedit, deleted the .slickedit directory, restarted slickedit, set Document->Indent with tabs, set Tools->Languages->Application Languages->C/C++->View->Special Characters, and when I hit tab in my C file it is inserting spaces. I then went into Tools->Languages->Application Languages->C/C++->Formatting->Edit and changed 'Indent with' from spaces to tabs. I then hit tab and still see spaces.

So, in some ways it is better, but I'm still not seeing tabs where I think I should be. Any thoughts?

Paul

ghamilto61

  • Community Member
  • Posts: 13
  • Hero Points: 0
Re: 4 tabs instead of 1 when tab inserted
« Reply #5 on: April 15, 2016, 05:24:08 pm »
I have seen cases where c language indent has a different idea of what the indent level ought to be for a given line.  For me it's always been the a case where the previous line is syntactically incorrect.  For example, if you are missing a ')' on the previous line, hitting tab will take you to the column one past the unmatched '('.

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1397
  • Hero Points: 128
Re: 4 tabs instead of 1 when tab inserted
« Reply #6 on: April 15, 2016, 05:39:52 pm »
Interesting, following your steps, I can get tabs after setting the Indent with Tabs in the Documents menu.

At this point, the default is tab width is 8, Syntax Indent is 4, so you need a couple of levels of indent to actually get the tabs.  So for instance:

Code: [Select]
void main()
{
....doSomething();
}

It's spaces at this point, because the indent is < the tab width.  I have to indent to another level to see tabs:

Code: [Select]
void main()
{
....doSomething();
....if (something) {
-------|somethingElse();
....}
}

Note that the tab also doesn't appear until you start typing something on that line.  Do you not get tabs even if you indent further than the tab width?

Paul9876

  • Junior Community Member
  • Posts: 9
  • Hero Points: 0
Re: 4 tabs instead of 1 when tab inserted
« Reply #7 on: April 15, 2016, 05:49:20 pm »
Patrick,

If I tab twice then I get a tab when I start typing; if I tab once then I get spaces as you indicated. So, it seems the confusing part to me is what does tab width mean and Syntax indent mean? I thought tab width meant go in by this number when the tab key is pressed. I'm not sure what syntax indent means. Also, what is the relationship between the 2?

Thanks for you help so far!

Paul

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1397
  • Hero Points: 128
Re: 4 tabs instead of 1 when tab inserted
« Reply #8 on: April 15, 2016, 06:17:13 pm »
Syntax Indent is how much we should indent things for the syntax of languages, regardless of whether tabs are spaces are being used to make the indent.  If you want the indent after a "{" to be 4, you set this to 4.

Tab width is just the width of the tab.

When your syntax indent is lower than the tab indent, then the indent code will put in spaces, because it's more concerned with getting the indent right than being strict on leading tabs.

If you go to Document -> C/C++ Options -> Formatting -> Indent -> ... and set the tab indent to be the same as the syntax indent, then you'll see behavior more like you're expecting.  But it still doesn't guarantee the leading indent will always be tabs, because things like continuations for function calls that span multiple lines can easily be at an indent that's not evenly divisible by the tab width; so you'll end up with N leading tabs + the remainder of the indent in spaces.

The other option is to change the indent style from Syntax to "Auto" or "None".  In that case, tabs should be tabs, but there will be no automatic indentation while editing.

Paul9876

  • Junior Community Member
  • Posts: 9
  • Hero Points: 0
Re: 4 tabs instead of 1 when tab inserted
« Reply #9 on: April 15, 2016, 06:46:15 pm »
Patrick,

OK, thanks for the explanation. I think setting the Syntax Indent to the same value as the tab width is what I want. The case you mentioned with a continuation would be problematic either way for us. I'll see how it goes.

Thanks again for your help!

Paul

ghamilto61

  • Community Member
  • Posts: 13
  • Hero Points: 0
Re: 4 tabs instead of 1 when tab inserted
« Reply #10 on: April 15, 2016, 08:21:33 pm »
It's interesting (if a little distracting) to make tabs visible for a while as you write code, especially if you're using different values for tab stop and indent.  It will give a feel for how it behaves and how you might change your settings to better suit your coding style.

Tim Kemp

  • Senior Community Member
  • Posts: 537
  • Hero Points: 91
Re: 4 tabs instead of 1 when tab inserted
« Reply #11 on: April 16, 2016, 03:38:37 pm »
...make tabs visible for a while as you write code...

I always have all whitespace visible. It feels weird to hide it.

Dan

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2506
  • Hero Points: 139
Re: 4 tabs instead of 1 when tab inserted
« Reply #12 on: April 18, 2016, 11:40:55 am »
I rarely show it in SlickEdit, but we generally do not use tabs, so there's less reason.  MS Word has a similar feature and there I would always use it because tabs are so critical there.