From 6291bd78ca4dd64a88c42d225bb25058ce86e767 Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Wed, 9 Sep 2015 17:09:56 -0500 Subject: [PATCH] Add Format Long Lines To Text Width as a vim til. --- README.md | 1 + vim/format-long-lines-to-text-width.md | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 vim/format-long-lines-to-text-width.md diff --git a/README.md b/README.md index 516af8f..d58958c 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/vim/format-long-lines-to-text-width.md b/vim/format-long-lines-to-text-width.md new file mode 100644 index 0000000..5804629 --- /dev/null +++ b/vim/format-long-lines-to-text-width.md @@ -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.