Friday, March 21, 2025

Re: BASH script: Indent with tabs, align with spaces

On Fri, Mar 21, 2025 at 08:15:37AM -0000, Steven H. wrote:
>
> #!/bin/bash⏎
> ⏎
> this␣--example␣\⏎
> >·······--example␣\⏎
> >·······⏎
>
> The correct result should be:
>
> #!/bin/bash⏎
> ⏎
> this␣--example␣\⏎
> ␣␣␣␣␣--example␣\⏎
> -----⏎

thank you for:
* spotting this bug
* providing me a very interesting case of macro debugging for my vim training

> Am I doing something wrong?

nope! I'm the one who did because in

s!\v^\s+\zs(\S+\s+).*!\=repeat(' ', 1 + len(submatch(1)))!

\v^\s+ means "at least one space at the begin of the line"
\v^\s* means "optional spaces at the begin of the line"

so you can fix the macro by yourself :)

regards

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/vim_use/Z90wFDzKD3WzRudv%40prometheus.

No comments: