0

I am new to vim and I want to use it for scripting Python3. anyone knows how to customize vim for editing Python 3 scripts? (mainly for indentations, coloring and tab suggestions... )

Thanks

2

2 Answers 2

2

Python wiki suggests putting the following in your ~/.vimrc:

syntax on
filetype indent plugin on
set tabstop=8
set expandtab
set shiftwidth=4
set softtabstop=4

Edit: the above does have the side-effect of using the tab settings in all files edited with vim. Other approaches are discussed in the wiki as well.

There's also the python.vim script for syntax highlighting and such.

Sign up to request clarification or add additional context in comments.

1 Comment

The two first line should be at the top of every /.vimrc but the other ones are somewhat python-specific. As such, they should be in ~/.vim/after/ftplugin/python.vim with setlocal instead of set.
1

You should put customized settings in to ~/.vim/ftplugin/python.vim This will be sourced when vim sees a file with a filetype python.

To make sure the settings only affect the current buffer use setlocal.

To make sure that mappings only affect the current buffer use noremap <buffer>

Just make sure to have filetype plugin indent on in ~/.vimrc

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.