Difference between revisions of "Python"
From Teknologisk videncenter
m (→Vim setting for python) |
m (→Vim setting for python) |
||
Line 12: | Line 12: | ||
===Vim setting for python=== | ===Vim setting for python=== | ||
add following lines in ~/.vimrc | add following lines in ~/.vimrc | ||
− | <source lang= | + | <source lang=text> |
"Python Settings | "Python Settings | ||
autocmd FileType python set softtabstop=4 | autocmd FileType python set softtabstop=4 |
Revision as of 09:45, 3 December 2023
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
" Map <F2> to write file and execute script in both command- and insert mode
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>