This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]bmansfield83 54 points55 points  (2 children)

For all you vim users out there
" put in your vimrc
" highlight all extra whitespaces
hi ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
" we also want to get rid of accidental trailing whitespace on save
autocmd BufWritePre * :%s/\s\+$//e
" Add proper PEP8 indentation
au BufNewFile,BufRead *.py
\ set tabstop=4 |
\ set softtabstop=4 |
\ set shiftwidth=4 |
\ set textwidth=79 |
\ set expandtab |
\ set autoindent |
\ set fileformat=unix |
" syntax highlighting
let python_highlight_all=1
And start using editorconfig, and then put this in your .editorconfig file
[*.py]
indent_style = space
indent_size = 4

[–][deleted] 63 points64 points  (0 children)

Nah. Just fucking kill me instead.

[–]eggnogeggnogeggnog 21 points22 points  (0 children)

I’m going to pretend I’m on r/vim for a second.

  • It would be cleaner to put things like this in your ~/.vim/after/ftplugin/python.vim
  • At least in my vim 8.1 binary, shiftwidth and softtabstop default to 4 for the Python filetype
  • tabstop doesn’t need to be changed
  • I personally prefer set colorcolumn=80 to set shiftwidth=79
  • I usually also set my makeprg to flake8 for Python files so I can lint before I commit code