1

As an evil I choose to use tabs. I'm having trouble getting them to work like they do in other editors.

I want displayed tabs aligned to 2 columns (with no exceptions).

I have tab-width set to 2, but when tabs begin on an odd column they become 3 columns wide. Standard editors align to the next tab stop so in this case they become only 1 column wide (which is what I want).

Examples (where 'T+' is a tab with 2 chars, and 'x' is an ordinary character):

xxT+xx // same alignment on emacs and standard editors.
xT++xx // emacs.
xTxx   // standard editors. (This is what I'm after)

How do I achieve this (preferably globally, but primarily for C/C++/bash/text).

Note: This question is entirely about the display of existing tabs.

  • There is a ton of confusion about what is "tab" in Emacs, so please be specific when you say "I have tab width set at 2". – Stefan Nov 7 '16 at 19:44
  • The variable named "tab-width" is set to 2, (I also played around with some other variables without success). However, I don't know if that's the variable I should be using, I'm just looking for any way to achieve the said alignment. – xaxazak Nov 7 '16 at 19:51
  • How do you know tab-width is set to 2? Where is it set to 2? It's a buffer-local variable, so setting it in your .emacs won't make a difference in your C-mode buffers. IOW be specific. – Stefan Nov 7 '16 at 20:07
  • I'm new to emacs (Kate's developed hideous bugs so I'm shopping for an alternative) so sorry if I'm not understanding how it all works yet. Options->Customize Emacs->Browse Customization Groups->Emacs->Editing->Editing Basics->Tab Width = 2. But my current setup isn't important - I just want to know how I should be achieving this. – xaxazak Nov 7 '16 at 20:22
  • If you set tab-width to a value other than the default you're likely to run into problems whenever you try to read code written by someone using a standard tab width. – Qudit Nov 7 '16 at 21:04
0

I cannot reproduce what you see. I've done the following:

emacs -Q
Options
-> Customize Emacs
-> Browse Customization Groups
-> Emacs -> Editing
-> Editing Basics
-> Tab Width
Replace the 8 with a 2
Click on `State` -> Set for Current Session

then I went back to *scratch* and typed

x C-q TAB xx

at which point I saw

xTxx

rather than the

xT++xx

[ where T and + both stand for whitespace. ]

  • Yes, you're right. I was using whitespace.el and I didn't realize this had any effect on layout (and I didn't know about -Q, that's handy, thanks). It seems whitespace.el is the source of the problem, now I just need to figure out why. – xaxazak Nov 7 '16 at 22:05
  • Thanks for your help. Seems I've hit this bug: emacs.stackexchange.com/questions/22357/… – xaxazak Nov 7 '16 at 22:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.