Monday, March 17, 2025

BASH script: Indent with tabs, align with spaces

Hi,

I am not very experience with Vim, still learning.

After lots of searching, I found that the only way to indent with tabs and align with spaces is to use the Smart Tabs plugin, so I installed it.

Unfortunately, what this gives me is:

--------------------
#!/bin/bash

f()
{
[tab]local a=1 \
[tab][tab]b=2

[tab]cmd1 --option1 "one" \
[tab][tab]--option2 "two" \
[tab][tab]arg1 \
[tab][tab]arg2 \
[tab][tab]| cmd2 --option3 "three" \
[tab][tab]--option4 "four" \
[tab][tab]arg3 \
[tab][tab]arg4 \
[tab][tab]arg5 \
[tab][tab]| cmd3 --option5 "five" \
[tab][tab]--option6 "six" \
[tab][tab]arg6 \
[tab][tab]arg7
[tab]}
--------------------

What I would like is:

--------------------
#!/bin/bash

f()
{
[tab]local a=1 \
[tab] b=2

[tab]cmd1 --option1 "one" \
[tab] --option2 "two" \
[tab] arg1 \
[tab] arg2 \
[tab] | cmd2 --option3 "three" \
[tab] --option4 "four" \
[tab] arg3 \
[tab] arg4 \
[tab] arg5 \
[tab] | cmd3 --option5 "five" \
[tab] --option6 "six" \
[tab] arg6 \
[tab] arg7
}
--------------------

My ~/.vimrc:

--------------------
filetype indent plugin on
colorscheme desert

syntax on
set hlsearch

set cursorline

highlight CursorLine ctermbg=Black ctermfg=none

set cursorcolumn
highlight CursorColumn ctermbg=Black ctermfg=none

highlight ColorColumn ctermbg=Black

set noexpandtab
set copyindent
set preserveindent
set softtabstop=0
set shiftwidth=8
set tabstop=8
set cindent
set cinoptions=(0,u0,U0

autocmd FileType json setlocal sts=2 sw=2

set list
set listchars=tab:\ \ ,trail:-,extends:>,precedes:<,nbsp:+
highlight SpecialKey ctermfg=grey ctermbg=black
--------------------

Another problem which I am facing after installing the Smart Tabs plugin:

If I use '==' to auto-format a line and then try to repeat it using '.', vim does not do what I want but shows an error message:

E774: 'operatorfunc' is empty


What is the solution to these 2 problems?

--
--
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/20250317125453.4c2db861%40localhost.

No comments: