anmnj
anmnj

Reputation: 1

Is there a setting in VSCode to adjust white space to keep tab stops aligned?

I am writing a python script where there are multiple declarations at once, and I use tabs to keep the dependent arguments aligned for readability. The issue is that VSCode doesn't seem to have a feature like MS Word where the white space within a tab stop region is modified to keep the trailing arguments in alignment. I'm very new to VSCode, so I've been just installing VSCode extensions and hoping they work.

I've had the same tidiness issue using PyQt6 and adding widgets to a grid layout

#                 temp          duration        cycle tag           cycle status
profile["p1"] = p(22,           1,              "A1",               o.COMPLETED)
profile["p2"] = p(100,           1,              "S1C",               o.COMPLETED)
profile["p3"] = p(80,           1,              "H1",               o.RAMPING_TO)
profile["p4"] = p(-70,           1,              "S1C",               o.NOT_COMPLETED)
profile["p5"] = p(-30,           1,              "C1",               o.NOT_COMPLETED)
profile["p6"] = p(35,           1,              "CUSP",               o.NOT_COMPLETED)
profile["p7"] = p(22,           1,              "A2",               o.NOT_COMPLETED)

I'm hoping that, regardless of how a leftward argument is adjusted, its rightward companions would remain at the tab stop as long as the leftward argument isn't so long to run into another tab stop iteration.

#                 temp          duration        cycle tag           cycle status
profile["p1"] = p(22,           1,              "A1",               o.COMPLETED)
profile["p2"] = p(100,          1,              "S1C",              o.COMPLETED)
profile["p3"] = p(80,           1,              "H1",               o.RAMPING_TO)
profile["p4"] = p(-70,          1,              "S1C",              o.NOT_COMPLETED)
profile["p5"] = p(-30,          1,              "C1",               o.NOT_COMPLETED)
profile["p6"] = p(35,           1,              "CUSP",             o.NOT_COMPLETED)
profile["p7"] = p(22,           1,              "A2",               o.NOT_COMPLETED)

Upvotes: -1

Views: 60

Answers (1)

anmnj
anmnj

Reputation: 1

Turns out I had two settings in conflict. Using this thread (Visual Studio Code - Convert spaces to tabs) I found that I had to uncheck both of these editor items:

VSCode editor screenshot

I only had the 'insert spaces' option unchecked. It seems that even though I used the tab character, if VSCode has the 'Editor: detect indentation' option checked, it will detect tab characters but will default to converting tabs to spaces still. So every new file will use spaces. Both need to be unchecked to use the tab character, allow tab stops locations to be respected, and keep that setting for new script files.

Upvotes: 0

Related Questions