How do I make text wrapping match current indentation level in vim?

丶灬走出姿态 提交于 2019-11-29 01:45:16
Don Werve

You're looking for breakindent

You may want to also refer to this thread.

retracile

I asked the same question on SuperUser, eventually found this question, found the patch, and updated the patch to work with Vim 7.2.148 from Fedora 11.

You can use yumdownloader --source vim to get the source RPM. Then add a Patch3312: line and a %patch3012 -p1 line to the spec file, and build the rpm.

Brian Dorsey

I recommend this vimscript:

http://www.vim.org/scripts/script.php?script_id=974

"This indentation script for python tries to match more closely what is suggested in PEP 8 (http://www.python.org/peps/pep-0008.html). In particular, it handles continuation lines implied by open (parentheses), [brackets] and {braces} correctly and it indents multiline if/for/while statements differently."

For controlling the indentation of Python code, see :h ft-python-indent. This for example will make Vim indent two times the shiftwidth if you do a newline while there's an unclosed paren:

let g:pyindent_open_paren = '&sw * 2'

However &sw * 2 is the default, so not sure why it's not working for you. It works for me with manual newlines or with textwidth-induced newlines.

The above setting needs to be in .vimrc or needs to be set somehow before Vim enters Python mode. Be sure to :setf python or that you're otherwise in Python mode.

I think set textwidth=80 should do it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!