Getting frustrated trying to setup my vim settings how I used to have them some years ago!

Just getting back into it after a few years and trying to set up Vim nicely how I remember it as when I started coding the settings came back to me of how I used to have them but been mucking about for about an hour now and not found what I want and frustrated as I want to get back to the project I was working on!

I am on Debian and apparently the update-alternatives preferred version is vim.gtk3, which I thought was the fully featured one? when I do some command I read on an article to check python compatbility with a a grep it shows both -python and +python but also a command shows +python3 so I am confused on where I stand in that department?

My current .vimrc:

autocmd BufNewFile,BufRead *.py set filetype=python
set showcmd
set viminfo="0"
set number
syntax on
set clipboard=unnamedplus
set autoindent expandtab tabstop=2 shiftwidth=2
set smartindent
filetype plugin indent on



What I was missing before was indenting when I do def function():. The last line has enabled indenting now but it is the 4 spaces where I want 2 spaces as per the settings above. So how to get to the right spacing? not been able to find how to change that.

Also how do I indent chunks of code? I know you can use V in Vim for that but I seem to remember there was another way when I was coding? If I write a chunk out of a function for example and decide to put it inside one after then how would I indent the chunk to the 2 spacing I want as my default?

I shall continue coding for now with the impoverished settings I have currently, eagerly awaiting replies. :slight_smile:

EDIT: Indenting just came back to me: Sh + >

Just have to know about the correct spacing for colon Enter.

I use something like autocmd filetype javascript setlocal expandtab shiftwidth=2 softtabstop=2 when the indentation is set as default to 4.
You might be better off in a Vim forum though!

These days Vim comes with a bunch of filetype plugins for various file types, including Python. Your filetype plugin indent on means that whenever you edit a .py file, the filetype plugin runs and overrides your globally-set shiftwidth and such.

To see why shiftwidth is set to 4, use :verbose set sw? and you’ll see something like

Last set from /usr/share/vim/vim91/ftplugin/python.vim line 119

If you want to override a filetype plugin, you can create a ~/.vim/after/ftplugin/python.vim with

setlocal shiftwidth=2 softtabstop=2

Thanks, I have it mostly working now but no idea what particular setting/s made it work.