AnswerBun.com

Vim indentation different on linux and macOS

Vi and Vim Asked by SniffDiff on December 20, 2020

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?

One Answer

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'.

Answered by Wolf on December 20, 2020

Add your own answers!

Related Questions

Turn syntax off only for current buffer/window?

1  Asked on January 30, 2021 by first-user

   

Concatenate mapping with zt mapping

2  Asked on January 21, 2021 by xxxo

     

Default rulerformat

1  Asked on January 6, 2021

     

keep contents of nofile buffer

1  Asked on January 2, 2021 by igor-semenov

 

how to use variables in vimscript shell commands

1  Asked on December 30, 2020 by alec

   

Vim feedkeys in operator pending mode

1  Asked on December 26, 2020 by myc3lium

   

Vim indentation different on linux and macOS

1  Asked on December 20, 2020 by sniffdiff

     

Is there a best practice to fold a vimrc file

8  Asked on December 20, 2020 by statox

   

:GhostInstall does not work

1  Asked on December 11, 2020 by soap

 

How to show the current location in a yaml hierarchy

3  Asked on December 3, 2020 by benjamin-reitzammer

   

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP