1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-04 23:58:01 +00:00

Add Format Long Lines To Text Width as a vim til.

This commit is contained in:
jbranchaud
2015-09-09 17:09:56 -05:00
parent feb0514f64
commit 6291bd78ca
2 changed files with 18 additions and 0 deletions

View File

@@ -163,6 +163,7 @@ smart people at [Hashrocket](http://hashrocket.com/).
- [Edges Of The Selection](vim/edges-of-the-selection.md)
- [End Of The Word](vim/end-of-the-word.md)
- [Filter Lines Through An External Program](vim/filter-lines-through-an-external-program.md)
- [Format Long Lines To Text Width](vim/format-long-lines-to-text-width.md)
- [Generate and Edit Rails Migration](vim/generate-and-edit-rails-migration.md)
- [Head of File Name](vim/head-of-file-name.md)
- [Help For Non-Normal Mode Features](vim/help-for-non-normal-mode-features.md)

View File

@@ -0,0 +1,17 @@
# Format Long Lines To Text Width
Vim allows you to set the maximum width for text per line in a buffer. For
example, you can set the maximum text width to 80 characters like so:
```
:set textwidth=80
```
With this set, vim will automatically break on whitespace whenever you hit
80 characters. There are two places where this doesn't quite pan out. You
will see this as soon as you open a file with lines of text that exceed 80
characters and when you paste long lines of text into your buffer. You can
quickly remedy this with `gw`.
Make a visual selection of the lines that need formatting and then hit `gw`.
All the lines should then we truncated to 80 or less characters.