Skip to content

Instantly share code, notes, and snippets.

@wmvanvliet
Last active May 5, 2020 19:40
Show Gist options
  • Save wmvanvliet/4aa309c2c3e7228060122e7beda14ece to your computer and use it in GitHub Desktop.
Save wmvanvliet/4aa309c2c3e7228060122e7beda14ece to your computer and use it in GitHub Desktop.
Vim keybinding for toggling PEP8 linting
" Linter (provided through ALE)
let g:ale_lint_on_text_changed = 'never'
let g:ale_lint_on_save = 1
let g:ale_linters = {
\ 'python': ['flake8'],
\}
" By default, don't worry about PEP8
let g:ale_python_flake8_options = "--ignore=E2,E3,E4,E5,E7,W"
let g:python_highlight_space_errors = 0
" Function to enable PEP8 checking
function! TogglePep8()
if g:ale_python_flake8_options == ""
let g:ale_python_flake8_options = "--ignore=E2,E3,E4,E5,E7,W"
setlocal colorcolumn=0
let g:python_highlight_space_errors = 0
else
let g:ale_python_flake8_options = ""
setlocal colorcolumn=80
let g:python_highlight_space_errors = 1
endif
endfunction
" Python PEP8 checking
nmap <leader>8 :call TogglePep8()<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment