vscode markdown-preview-enhanced 配置 等宽字体

前提:

1. VSCode中,Ctrl + Shift + P (或者F1),点击Markdown Preview Enhanced: Customize CSS (Global)

配置css

.markdown-preview.markdown-preview {
  // modify your style here
  // eg: background-color: blue;
  pre,
  pre code,
  code {
    font-family: "Sarasa Mono SC", "Sarasa Fixed SC", "Sarasa Mono SC Fixed", NSimSun, monospace !important;
    font-size: 16px !important;          // 偶数像素,避免半角宽度取整误差
    line-height: 1.5 !important;
    white-space: pre !important;          // 不折行,保留原始列对齐
    tab-size: 4;
    -moz-tab-size: 4;
    font-variant-ligatures: none !important;     // 关闭连字,避免字符合并影响列宽
    font-feature-settings: "liga" 0, "calt" 0 !important;
    letter-spacing: 0 !important;
    word-break: keep-all !important;
  }
}

 

2. 在编辑md文件时,想要呈现同样的效果,则F1,配置Preferences: Open User Settings (JSON)

新增如下内容即可

    "[markdown]": {
        "editor.fontFamily": "'Sarasa Fixed SC', monospace",
        "editor.fontSize": 14,
        "editor.lineHeight": 1.4
    }

  

posted @ 2026-06-22 10:25  人间春风意  阅读(17)  评论(0)    收藏  举报