I have some code I copy-paste from somewhere. What is this how to get rid of them all at once?

enter image description here

My emacs is setup to automatically cut the orange areas, but to get rid of these?


             position: 16165 of 16950 (95%), column: 0
            character: TAB (displayed as TAB) (codepoint 9, #o11, #x9)
    preferred charset: ascii (ASCII (ISO646 IRV))
code point in charset: 0x09
               script: latin
               syntax:      which means: whitespace
             to input: type "C-x 8 RET HEX-CODEPOINT" or "C-x 8 RET NAME"
          buffer code: #x09
            file code: #x09 (encoded by coding system undecided-unix)
              display: by display table entry [?→ ? ] (see below)

The display table entry is displayed by these fonts (glyph codes):
→: xft:-MS  -Consolas-normal-normal-normal-*-23-*-*-*-m-0-iso10646-1 (#x365)
    : -- no font --

Character code properties: customize what to show
  general-category: Cc (Other, Control)
  decomposition: (9) (' ')

There is an overlay here:
 From 16165 to 16165
  before-string        [Show]
  linum-str            [Show]

There are text properties here:
  face                 whitespace-tab
  fontified            t
  • 1
    Did you accidentally activate whitespace-mode? If not, does the problem persist if you shut down Emacs and open it up again? – Tianxiang Xiong Sep 17 '16 at 3:07
  • @TianxiangXiong, no. it's not the code I've written. – Johshi Sep 17 '16 at 3:07
  • 2
    Are you sure you didn't activate whitespace-mode? That looks a lot like whitespace-mode. M-x whitespace-mode to deactivate. – Tianxiang Xiong Sep 17 '16 at 3:11
  • @TianxiangXiong, I'm sure --` "(add-hook 'before-save-hook 'delete-trailing-whitespace)"` . But as I've said, those areas are red, whereas 'delete-trailing-whitespace deletes only orange ones. – Johshi Sep 17 '16 at 3:17
  • 1
    You've disabled what? Automatically delete what? – Drew Sep 17 '16 at 3:20

If I understand correctly, OP is an Emacs newbie trying to turn tabs into spaces in his buffer.

Try the following:

(customize-set-variable 'indent-tabs-mode nil)
(add-hook 'before-save-hook #'whitespace-cleanup)

You don't need delete-trailing-whitespace anymore.

| improve this answer | |
  • what does that do? – Johshi Sep 17 '16 at 3:24
  • But maybe he just wants to stop highlighting Tabs, instead of converting them to spaces. whitespace-styles is where to do that. Also, turning off indent-tabs-mode doesn't convert existing Tabs. For that, you need to use untabify: C-x h to select all the text, then M-x untabify. – Drew Sep 17 '16 at 3:24
  • @Drew, I don't want to stop highlighting Tabs, – Johshi Sep 17 '16 at 3:25
  • select the whole buffer, then M-x untabify might be what you want. @Drew mentioned it... – Xah Lee Sep 17 '16 at 3:26
  • untabify will remove tabs from the current buffer; putting whitespace-cleanup in before-save-hook will eliminate all future whitespace problems. – Tianxiang Xiong Sep 17 '16 at 3:27

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.