Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I change font of comments in visual studio code?

After watching a Sublime3 screencast by a famous python programmer, I found that display code comment in a fancy font is a great idea, which let comment more distinguishable and makes comment reading more pleasant. One example is like below:

sublime text 3 screencast

In this demo, code comment is shown in a light color hand-written like font, making it easier to be distinguished from the real code and keeping the comment fun to read at the same time.

I went through https://code.visualstudio.com/docs/getstarted/ but can't seem to find the setting for changing the comment font for code.

So I am wondering how to set a another font for comment against normal code font.

like image 903
pambda Avatar asked Mar 07 '18 09:03

pambda


People also ask

How do I change the comment font in VS Code?

Open your VS editor. Navigate to the upper part of the screen and select File. Now, in the drop-down menu, go to Preferences > Settings. You'll now see the Commonly Used section with a menu on the right-side of the screen, you can access the font from this page or by following the step below.

How do you beautify text in VS Code?

The code formatting is available in Visual Studio Code through the following shortcuts: On Windows Shift + Alt + F. On Mac Shift + Option + F. On Linux Ctrl + Shift + I.


1 Answers

Download font https://www.dafontfree.net/freefonts-script12-bt-f141942.htm

Install package https://github.com/be5invis/vscode-custom-css

Create new css file ~/.vscode/vs-code-styles.css

Paste in this CSS:

/* Set italics and comments to the script font */
.mtk3, .mtk4 {
    font-family: 'Script12 BT';
    font-size: 1.2em;
    font-style: normal;
    color: #57a649!important;
}
.comment {
  font-family: 'Script12 BT';
  font-style: italic;
  font-size: 1.2em;
  color: #57a649!important;
}
.comment:not(.punctuation) {
    font-family: 'Script12 BT';
    font-size: 1.5em;
    color: #57a649!important;
}

Go to Code > Preferences > User Settings

// Somewhere in your user / workspace settings file !

.
.
.
.

"vscode_custom_css.imports": ["file:///<PATH TO CSS FILE>/.vscode/vs-code-styles.css"],
"vscode_custom_css.policy": true,
"editor.tokenColorCustomizations": {
    "textMateRules": [
        {
            "scope": "comment",
            "settings": {
                "fontStyle": "italic"
            }
        }
    ]
}

Source: https://gist.github.com/psgganesh/d0815ece4b19ce24dde98e21d55f53f5

like image 55
kurdtpage Avatar answered Oct 03 '22 07:10

kurdtpage