Wednesday, June 08, 2022

Re: mg: how to indent using spaces instead of tabs

On 2022-06-07 16:07 -0700, obsdml@loopw.com wrote:
> Mixing tabbed and spaced indenting is horrific in an indent specified
> language.

Unfortunately, that is precisely what mg's auto-indent-mode does.

This Python file uses four spaces for indentation:

if True:
while True:
print('Hello')

Let's open that file in mg and enable auto-indent-mode. If we move our
cursor to the end of the third line, press "Enter", mg will use a tab
for indentation.

if True:
while True:
print('Hello')
print('world')

As you probably know, Python will complain if a mix of tabs and spaces
is used:


File "example.py", line 4
print('world')
^
TabError: inconsistent use of tabs and spaces in indentation


If the size of the tab on screen is 8 spaces, it will not be possible to
visually distinguish between tabs and spaces ... mg doesn't have a
setting to visually distinguish between tabs and spaces (something
similar to ':set list' in vi).

Because it so strongly prioritizes tabs, it appears that mg is
unsuitable for programming Python with other people when other people
use spaces for indentation.

No comments:

Post a Comment