Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: automatically trim indentation #213

Open
DrKGD opened this issue Nov 1, 2022 · 0 comments
Open

Feature request: automatically trim indentation #213

DrKGD opened this issue Nov 1, 2022 · 0 comments

Comments

@DrKGD
Copy link

DrKGD commented Nov 1, 2022

Would it be possible to include an autogobble (I was thinking of lstautogobble package for lstlisting, LaTeX) flag onto the silicon binary?

E.g. of source code

			local _status = { }
				-- Left components
				_status[1] = { }
					table.insert(_status[1], ux.half_sx)
					table.insert(_status[1], uc.editor.state)
					table.insert(_status[1], ux.half_dx)

Setting the initial indentation to the first actual line of code

local _status = { }
	-- Left components
	_status[1] = { }
		table.insert(_status[1], ux.half_sx)
		table.insert(_status[1], uc.editor.state)
		table.insert(_status[1], ux.half_dx)

It is surely possible with the aid of external tools, for example the following one-liner:

  1. Greps, thus retrieve only the indentation characters
  2. Get the least possible amount
  3. With cut, make the line start from the nth character (cut -c "${nth}-") instead
cut -c "$(grep -oP '^\t*' testcase | awk '{ print length+1 }' | sort -nu | head -n1)-" testcase
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant