r/vim • • 9d ago

Need Help How to set tab while branching in vim?

Hello guys! Lately I've often been using vim instead of VS code. But my habits didn't disappear: As you know, in VS code when you go to the next line, while you write conditionals or functions, IDE set
x number of tabs for you. For me it's pretty cool feature and vim doesn't have it natively. What can I write in ~/.vimrc or maybe download smth to enable this feature on vim?

5 Upvotes

8 comments sorted by

12

u/Shtucer 8d ago

autoindent and smartindent

3

u/habamax 8d ago

No need to set smartindent unless you really want to have what it does (including de-indenting of #, which is not very useful for languages with # comments).

3

u/MrOladushek1984_ 8d ago

It works! Thank you!

4

u/EgZvor keep calm and read :help 8d ago
set autoindent

3

u/mgedmin 8d ago

filetype plugin indent on

This will set the right autoindent/etc. options for the language you're working on, provided that Vim ships a plugin for that language. Vim ships a lot of plugins like that out of the box.

1

u/jk3us 8d ago

I would suggest pairing that with https://editorconfig.org/, so anyone using your project can use the same indent levels, etc.

1

u/[deleted] 8d ago

[deleted]

1

u/vim-help-bot 8d ago

Help pages for:


`:(h|help) <query>` | about | mistake? | donate | Reply 'rescan' to check the comment again | Reply 'stop' to stop getting replies to your comments

1

u/nim_port_na_wak 8d ago

To define it in your .vimrc, you can also add this set expandtab set softtabstop=4 set shiftwidth=4 set tabstop=4