Python

From Teknologisk videncenter
Revision as of 10:34, 3 December 2023 by Heth (talk | contribs)
Jump to: navigation, search


Programming style

  • Recomended indent - 4 spaces
pip install reindent  # Pyhon reindent script
reindent my_script.py

Vim setting for python

add following lines in ~/.vimrc

"Python Settings
autocmd FileType python set softtabstop=4
autocmd FileType python set tabstop=4
autocmd FileType python set autoindent
autocmd FileType python set expandtab
autocmd FileType python set textwidth=80
autocmd FileType python set smartindent
autocmd FileType python set shiftwidth=4
autocmd FileType python map <buffer> <F2> :w<CR>:exec '! python' shellescape(@%, 1)<CR>
autocmd FileType python imap <buffer> <F2> <esc>:w<CR>:exec '! python' shellescape(@%, 1)<CR>