0

I have found the setting that are currently working for me for python development in vim.

"set tabs to have 4 spaces
set ts=4

" expand tabs into spaces
set expandtab

" enable all Python syntax highlighting features
let python_highlight_all = 1

The issue is, that these settings are getting in the way when opening other documents, for example Makefiles.

Is it possible to use these settings to apply only for *.py files?

marked as duplicate by nobe4, SibiCoder, mMontu, Antony, Tommy A Jun 30 '16 at 13:00

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

3

You are looking for autocommands, something like this:

autocmd FileType python setlocal showmatch

Would set the showmatch option only on buffers with the python filetype.

See :h :autocmd.

" ###############################
" Settings I want for all files #
" ###############################


" enable syntax highlighting for all the languages vim recognizes by default
syntax enable

" indent when moving to the next line while writing code
set autoindent

" show the matching part of the pair for [] {} and ()
set showmatch

" ########################################
" Settings related to python development #
" ########################################


autocmd Filetype    python 
                \   setlocal ts=4 |
                \   setlocal expandtab 

" enable all Python syntax highlighting features
" it doesn't highlight issues on other files even 
" though it's not in autocmd. Don't know
let python_highlight_all = 1 

Not the answer you're looking for? Browse other questions tagged or ask your own question.