---
title: Wrap Existing Text at 80 Characters in Vim
teaser:
tags: vim
author: Dan Croak
published_on: 2013-04-07
---

You have an existing block of text or code in vim. You want to re-format it to
wrap to 80-characters.

    :set textwidth=80

You might want this setting to apply automatically within certain file types
like Markdown:

    au BufRead,BufNewFile *.md setlocal textwidth=80

We have that setting in [thoughtbot/dotfiles][1].

Select the lines of text you want to re-format:

    v

Reformat it:

    gq

Learn more:

    :h gq

[1]: https://github.com/thoughtbot/dotfiles/blob/master/vimrc

## What's next

If you found this useful, you might also enjoy:

* [Sorting Lines Alphabetically in Vim][sort]
* [Onramp to Vim][onramp]

[sort]: https://thoughtbot.com/blog/sort-lines-alphabetically-in-vim
[onramp]: https://thoughtbot.com/upcase/onramp-to-vim
