How to stop line breaking in vim

前端 未结 11 2032
执笔经年
执笔经年 2020-12-12 10:06

I like that the long lines are displayed over more than one terminal line; I don’t like that vim inserts newlines into my actual text. Which part of .vimrc I should change?

11条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-12 10:49

    I personnally went for:

    • set wrap,
    • set linebreak
    • set breakindent
    • set showbreak=ͱ.

    Some explanation:

    • wrap option visually wraps line instead of having to scroll horizontally
    • linebreak is for wrapping long lines at a specific character instead of just anywhere when the line happens to be too long, like in the middle of a word. By default, it breaks on whitespace (word separator), but you can configure it with breakat. It also does NOT insert EOL in the file as the OP wanted.
    • breakat is the character where it will visually break the line. No need to modify it if you want to break at whitespace between two words.
    • breakindent enables to visually indent the line when it breaks.
    • showbreak enables to set the character which indicates this break.

    See :h within vim for more info.

    Note that you don't need to modify textwidth nor wrapmargin if you go this route.

提交回复
热议问题