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

前端 未结 5 1330
无人及你
无人及你 2020-12-16 00:28

Does anyone know of a way to get vim to wrap long lines of text such that the position of the wrapped text is based on the indentation of the current line? I don\'t want to

5条回答
  •  有刺的猬
    2020-12-16 01:02

    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.

提交回复
热议问题