JosephStyons
JosephStyons

Reputation: 58685

How can I make Visual Studio wrap lines at 80 characters?

Is there any way to make Visual Studio word-wrap at 80 characters? I'm using VS2008.

This post is loosely related.

Upvotes: 144

Views: 193389

Answers (13)

Trey Mack
Trey Mack

Reputation: 4695

https://csharpier.com/ wraps to less than 80 characters. It's a good option for legibility.

Upvotes: 1

Dima
Dima

Reputation: 1761

I have created a .NET analyzer to get warnings (code LK0080) on your warnings list whenever you cross the 80 chars limit. It is NuGet package: LeetKean.Analyzers.LineLength

Upvotes: 0

Ogglas
Ogglas

Reputation: 69928

VS only supports Word Wrap. At least up until latest 17.7.4 version available today. There is a issue to support max_line_length for editorconfig but it probably wont be implemented anytime soon. The issue has been there since 2019.

On another note I think you should read Linus Torvalds note from Linux Kernel Mailing List on 80 characters per row limit here. Good points about why excessive line breaks can be bad.

Upvotes: 3

Igal Tabachnik
Igal Tabachnik

Reputation: 31548

Unless someone can recommend a free tool to do this, you can achieve this with ReSharper:

ReSharper >> Options... >> Languages/C# >> Line Breaks and Wrapping

  • Check "Wrap long lines"
  • Set "Right Margin (columns)" to the required value (default is 120)

Upvotes: 134

niros calfon
niros calfon

Reputation: 1

You can enable word wrap and set zoom of code for 207% and that will show wrap every line of code that is over 80 characters in length.

Upvotes: 0

HelloGoodbye
HelloGoodbye

Reputation: 3902

If the problem is simply that you want to know when you pass 80 characters for a single line, which is a common coding guideline limit, you can use a different approach: Editor Guidelines. This will add vertical column guides behind your code.

Upvotes: 4

Corio
Corio

Reputation: 395

I stumbled upon this question when was actually searching for an answer to this one (how to add a visual line/guideline at char limit). So I would like to leave a ref to it here for anyone like myself.

Upvotes: 5

Cory Koch
Cory Koch

Reputation: 514

You can also use

Ctrl+E, Ctrl+W

keyboard shortcut to toggle wrap lines on and off.

Upvotes: 26

user1108948
user1108948

Reputation:

Adds vertical column guides to the Visual Studio text editor. This version is for Visual Studio 2012, Visual Studio 2013 or Visual Studio 2015.

See the plugin.

Upvotes: 5

Roland Pihlakas
Roland Pihlakas

Reputation: 4573

See also this answer in order to switch the mode conveniently.

Citation:

I use this feature often enough that I add a custom button to the command bar.

Click on the Add or Remove -> Customize
Click on the Commands tab
Select Edit|Advanced from the list
Find Toggle Word Wrap and drag it onto your bar

Upvotes: 0

idbrii
idbrii

Reputation: 11916

To do this with Visual Assist (another non-free tool):

VAssistX >> Visual Assist X Options >> Advanced >> Display

  • Check "Display indicator after column" and set the number field to 80.

Upvotes: 9

Stewart Johnson
Stewart Johnson

Reputation: 14449

I don't think you can make VS wrap at 80 columns (I'd find that terribly annoying) but you can insert a visual guideline at 80 columns so you know when is a good time to insert a newline.

Details on inserting a guideline at 80 characters for 3 different versions of visual studio.

Upvotes: 38

TGnat
TGnat

Reputation: 4001

Tools >> Options >> Text Editor >> All Languages >> General >> Select Word Wrap.

I dont know if you can select a specific number of columns?

Upvotes: 85

Related Questions