Friday, June 27, 2025

Re: Indent block inline with other blocks is too far

On 27.06.25 02:12, K otgc wrote:
> Hello,
> I'm indenting a code block by highlighting the block and then selecting the
> greater than key.
> However this indents the block 8 spaces, which is too far past the other
> code blocks, which are only 2 spaces indented.
> I am using version: VIM - Vi IMproved 8.1 (2018 May 18, compiled Apr 02
> 2025 16:39:51)
> Is there a way to adust the indent please?

In .vimrc, set "tabstop". For a couple of decades, I've had:
set tabstop=3 expandtab ai
as a 3-space tab looks good on an "if" block.
Expanding tabs to an equivalent number of spaces avoids indenting changing when you share the code with someone from last century, still stuck on 8-space tabs.
Setting autoindent (aka ai) causes "Copy indent from current line when starting a new line (typing <CR> in Insert mode or when using the "o" or "O" command)." as ":help ai" explains.

If you also:
set listchars=tab:>-,trail:-
then tabs will be shown as '>', and trailing spaces as '-'. If a shared
file comes back with tabs, rather than being entirely space-expanded,
then that's visible, and you can then expandtab with your tabstop
setting, forcing consistency.

Erik


--
--
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/19f2ed8d-40cb-4478-84d6-f3a427270943%40localhost.

No comments: