Question

I'm using the plugin Python-Mode, which has an PymodeLintAuto feature which 'Fix PEP8 errors in current buffer automatically'. I was wondering how I could change the max line length for that was. I couldn't find in the docs

Was it helpful?

Solution 3

If Python-Mode is using PyLint, you can specify what errors you wish for it to raise. This involves creating a customised pylint.rc and then giving that to pymode using a setting in your .vimrc.

.vimrc:

" Pylint configuration file
let g:pymode_lint_config = '$HOME/pylint.rc'

pylint.rc:

[FORMAT]

# Maximum number of characters on a single line.
max-line-length=120

OTHER TIPS

To change max line length in pymode you change

g:pymode_options_max_line_length

with let.

However this does not work for me, so do as @dillbert suggested. For the colorbar:

autocmd FileType python set colorcolumn=120

in your .vimrc

In recent (as of June 2018) python-mode versions, the required configuration seems to be this:

let g:pymode_options_max_line_length = 88
let g:pymode_lint_options_pep8 = {'max_line_length': g:pymode_options_max_line_length}
let g:pymode_options_colorcolumn = 1

I tried the above answers, but none works, I have to write hard code the python-mode. Here is my solution:

Find pep8.py in your .vim, my is under /Users/chaopeng/.vim/bundle/Python-mode-klen/pylibs/pylama/pep8.py, then replace 79 with 119 in pep8.py.

And don't miss

let g:pymode_options_max_line_length=120
autocmd FileType python set colorcolumn=120
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top