How to turn word wrap on or off in Vim
Type :set nowrap and press ↵ to keep each long line on one screen row, and :set wrap to wrap them at the window's edge again. That only changes the view. For real line breaks, type :set textwidth=72, then gqip in the paragraph.

The burrito shop's specials.js opens with a comment about the Friday special that runs past 80 characters, and your terminal is half the screen wide because the menu is open beside it. Vim carries the comment on to a second row at the window's edge, often in the middle of a word. That's the wrap option, on out of the box, and it changes only what you see. In the file, the comment is still one line.
:set nowrap keeps every line on a single row and cuts it off at the edge. Move the cursor along the line and the view slides sideways to follow it. :set wrap turns wrapping back on, and :set wrap! switches to whichever one is off.
Wrap on and off
Type each command as you would in Vim, Enter included.
Wrap between words, and move one row at a time
Vim wraps a line at the last character that fits, so a word can start on one row and finish on the next. :set linebreak makes it wrap at a space or a punctuation mark instead. Like wrap, it only changes the screen, and it does nothing while wrap is off.
A wrapped line is still one line, so j (down) and k (up) jump over all of its rows at once. In a README where every paragraph is one long line, j skips a whole paragraph. gj and gk move down and up one row of the screen instead.
Prose that wraps
Break the text into real lines
Wrapping on the screen is no help when the breaks have to be in the file. A commit message is the usual case. You've added the birria special, and git commit has opened Vim for the message. Git keeps the body exactly as you type it, and the custom is to keep its lines to 72 characters. You pasted the first paragraph in from the kitchen's group chat, where it was one long line.
:set textwidth=72 sets the width. gq rewraps text to it, breaking long lines at spaces and joining short ones. It works like d, with a motion or a text object after it, so gqip rewraps the paragraph the cursor is in (ip is the run of lines between two blank lines). While textwidth is 0, its default, gq wraps at the window's width, up to 79.
Wrap the commit message
The cursor is at the start of the long paragraph. Git's notes at the bottom stay as they are.
:set textwidth=72 and ↵, then rewrap the paragraph with gqipCOMMIT_EDITMSGThis editor needs a keyboard. Read on, and play it at your computer.
Rewrap a paragraph after you edit it
A wrapped paragraph doesn't stay tidy once you edit it. You decide the kitchen screen should show a lime wedge icon too, type that into the second paragraph, and now its first line runs long. gqip would fix it and leave the cursor on the paragraph's last line. gwip rewraps it the same way and leaves the cursor where it was, so you can carry on typing. To rewrap only the line you're on, use gqq.
Tidy the second paragraph
The cursor is on lime, where you just typed.
limeCOMMIT_EDITMSGThis editor needs a keyboard. Read on, and play it at your computer.
Wrap as you type, and see the limit
With textwidth set, Vim also breaks lines while you type in Insert mode. When a word would go past the width, it moves down to a new line. Neovim, and Vim with file type plugins on, set textwidth to 72 for Git commit messages by themselves, so there you get this without asking.
To see where the limit is, :set colorcolumn=80 colours column 80 all the way down the window. :set colorcolumn=+1 puts the stripe one column past textwidth, whatever that is.
Widths from memory
Type each one as you would in Vim, Enter included where there is a command line.
Keep your wrap settings
:set lasts until you close Vim. To keep a setting, put the same words in ~/.vimrc, without the colon. If you'd rather scroll sideways through long lines of code, that's set nowrap. If you mostly write prose and want it wrapped between words, it's set linebreak.
textwidth is better kept to the files that are prose, so Vim doesn't break your code as you type. autocmd FileType markdown,text setlocal textwidth=80 sets it for Markdown and plain text, as long as it comes after the filetype plugin indent on line. To have j and k move by screen row, nnoremap <expr> j v:count ? 'j' : 'gj' (and a matching line for k with gk) does it while a count such as 5j still moves by real lines.
In Neovim's init.lua the options are vim.opt.wrap = false and vim.opt.linebreak = true, and any Vim line, such as the autocmd, can go to vim.cmd as a string. Your Vim config, line by line goes through the rest of a config.
Add it to your vimrc
Your ~/.vimrc has one line so far. Add linebreak below it.
set linebreak, then press Esc.vimrcThis editor needs a keyboard. Read on, and play it at your computer.
| Type | What it does |
|---|---|
:set wrap ↵ | Wrap long lines at the window's edge (on by default). Changes the view, not the file. |
:set nowrap ↵ | Keep each line on one row and cut it off at the edge. :set wrap! switches between the two. |
| zl / zh | With nowrap, slide the view one column right or left. |
:set linebreak ↵ | Wrap between words instead of mid-word (lbr). Display only. |
:set breakindent ↵ | Start each wrapped row at the line's own indent (bri). |
| gj / gk | Down or up one row of the screen. |
| g0 / g$ | To the start or end of the row you are on. |
:set textwidth=72 ↵ | The width for gq and for breaking lines as you type (tw). At 0, nothing breaks as you type and gq uses the window, up to 79. |
| gqip | Rewrap the paragraph. The cursor ends on its last line. |
| gqq / gqj | Rewrap this line, or this line and the next (gq takes any motion). |
| gwip / gww | Rewrap the paragraph or the line, and leave the cursor where it was. |
| V, then gq | Rewrap the lines you selected. |
:set colorcolumn=80 ↵ | Colour column 80 (cc). +1 means one past textwidth. |
" ~/.vimrc " nothing yet: Vim's defaults