Skip to content
This repository has been archived by the owner on Jul 29, 2023. It is now read-only.

Indented lines of four lengths #358

Open
SlRofa-SUSE opened this issue Jun 26, 2021 · 2 comments
Open

Indented lines of four lengths #358

SlRofa-SUSE opened this issue Jun 26, 2021 · 2 comments

Comments

@SlRofa-SUSE
Copy link

Hello, the default indent line is 8 spaces indented once, how can I set it to 4 spaces.

@chuckdavisson
Copy link

There are a couple of ways. I'm assuming that you're using vim, so:

You could add this to your .vimrc file:
set tabstop=4 " number of visual spaces per TAB
set softtabstop=4 " number of spaces per tab when editing
set shiftwidth=4 " spaces to insert or remove using the indentation commands
set expandtab " tabs are spaces

OR, if you want different spaces for different purposes, for example 4 spaces per tab for Python, 2 spaces for YAML files, you could add this to your .vimrc file instead of the above:

" Shell
autocmd Filetype sh setlocal tabstop=4 shiftwidth=4 softtabstop=4 expandtab
" Python
autocmd Filetype py setlocal tabstop=4 shiftwidth=4 softtabstop=4 expandtab
" YAML
autocmd Filetype yaml setlocal tabstop=2 shiftwidth=2 softtabstop=2 expandtab
autocmd Filetype yml setlocal tabstop=2 shiftwidth=2 softtabstop=2 expandtab
" JSON
autocmd Filetype json setlocal tabstop=2 shiftwidth=2 softtabstop=2 expandtab
" Jinja 2
autocmd Filetype j2 setlocal tabstop=2 shiftwidth=2 softtabstop=2 expandtab

Note that the " in the .vimrc file just indicates that the line is a comment

There's probably other (better) ways to do what you're asking, but this is how I do it.

Hope that helps!

@SlRofa-SUSE
Copy link
Author

Thank you. It is now shown in four spaces.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants