How do I change the line spacing in Visual Studio

2020-05-21 09:15发布

问题:

Is it possible to change the spacing between lines in the Visual Studio 2012 code editing area? After having worked with IntelliJ IDEA for a while, I got accustomed to a slightly larger line spacing (1.2), and I want to achieve the same effect in VS12. For comparison, the top one is IDEA with 12 pixels spacing between lines, the bottom one is VS12 with 10 pixels spacing:

I find the IDEA version much easier to read, even if it's just 2px difference. Does anyone know?

回答1:

I've found a workaround which works pretty well, partly alread described in this comment.
You need to download and install TypeLight (free for personal use), and open the Consolas.ttf file inside. To adjust the line spacing, go to Font -> Metrics -> Advanced and change the "Line Gap" to your desire (I changed "Type Line Gap" as well, but I have no idea what this actually does). I experimented a bit with a values and found around 730 to be similar to the 12 pixels spacing in IDEA.

To distinguish the modified font from the regular Consolas, I suggest changing the name of the font under Font -> Names (to "Consolas Spaced" or something). Save the font, double-click the file and choose "Install" from the preview dialog. Then (re)start Visual Studio, choose your modified font and you're done.



回答2:

Can't change directly in Visual studio.
--> BUT You CAN change line height of font, the font you're using.
Step 1: install Fontforge.
Step 2: Open Fontforge after install finished, go to:
Element->Font Info ->OS2 -> Unit.
Change 4 value: Down win, up win, top N, down horizontal by multiplied by the desired ratio. Sample: ratio 1.5 or 2 ..etc...
(it means: if default 800, you multiple with ratio 1.5 --> result is 1200, you change 800 -->1200)
--> click OK to save setting.
Step 3: Go to File -> Generate font --> Generate with ttf format.
Step 4: Install the font just created and change font in Visual Studio.