Friday, March 21, 2025

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

I changed the trail symbol for better visibility below.

This:

set listchars=eol:⏎,tab:>·,trail:▪,space:␣,extends:>,precedes:<,nbsp:+
set ai ci
command -nargs=0 ArgIndent {
y | put
s!\v^\s*\zs(\S+\s+).*!\=repeat(' ', 1 + len(submatch(1)))!
}
inoremap \<cr> <c-o>:ArgIndent<cr>

gives me:

#!/bin/bash⏎

this␣--example▪⏎
␣␣␣␣␣--example▪▪⏎
␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣--example▪▪⏎
␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣--example▪▪⏎
▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪⏎

As you see, pressing Enter makes the backslash disappear. Also, as soon
as Enter is pressed, all 'this' and '--example' strings appear on a
different background (light gray in my case with 'colorscheme desert'
which I use).

Please advise how to fix it.
Thanks.

--
--
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/20250321151437.2f94f429%40localhost.

No comments: