I'm using vim to write in C for college. My .c files need to abide to specific formatting rules. While I'm writing my files on Linux, the .c files will be evaluated on macOS. I noticed that any tabs on lines with a "*" character will register as spaces on macOS. This is completely invisible to me on Linux and I can only see this once I open my files on a Mac.

Strangely the program that the school provides to check my formatting does detect the lack of tabs(on linux). But according to vim those lines contain tabs.

Why is this happening and can I fix it?

  • 1
    Welcome to Vi and Vim! In addition to the answer about expandtab and list/chars, you might want to double-check the various indent settings (smartindent, autoindent, indentexpr) and the various indent-width settings (tabstop, shiftwidth, shiftround, softtabstop)
    – D. Ben Knoble
    Nov 3, 2020 at 13:19

1 Answer 1


In your Vim you may have exandtab set which will cause your tabs to be expanded into spaces. See :help 'expandtab'. You can change this in your .vimrc by saying set noexpandtab. Files you have now that need to fixed can be converted by running the :retab command. See :help retab.

You can also see tabs and spaces in your file by enabling setting list, e.g., :set list. This makes whitespace visible and can be controlled by changing the listchars setting. See :help 'list' and :help 'listchars'.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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