How to stop line breaking in vim
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?
Solution 1:
Use
:set wrap
To wrap lines visually, i.e. the line is still one line of text, but Vim displays it on multiple lines.
Use
:set nowrap
To display long lines as just one line (i.e. you have to scroll horizontally to see the entire line).
Solution 2:
I like that the long lines are displayed over more than one terminal line
This sort of visual/virtual line wrapping is enabled with the wrap
window option:
:set wrap
By default this will wrap at the first character that won't fit in the window. This means it will wrap in the middle of a word if that's where the window boundary lies. To change it to wrap on word boundaries, you can also:
:set linebreak
This will cause wrap
to only wrap at the characters in the breakat
setting, which defaults to space, tab, and small set of punctuation characters.
:set breatat
breakat= ^I!@*-+;:,./?
I don’t like that vim inserts newlines into my actual text.
To turn off physical line wrapping, clear both the textwidth
and wrapmargin
buffer options:
:set textwidth=0 wrapmargin=0