Per-token font size in Sublime Text 2

末鹿安然 提交于 2019-11-26 21:41:52

问题


Apologies if this has already been answered but I couldn't find any duplicates.

Is it possible to set font sizes on a per-token basis in Sublime Text 2? For example, all 'function' tokens would be size 10 whereas 'functionName' would be size 30? I've put together a rough mock-up of what I want to achieve:

The motivation here is to make it easier for you to focus on the important parts of your code - especially when skimming. I would suspect that such a thing should be possible given that, by default, ST2 already applies different fonts to different tokens (e.g. 'var' vs. 'c = a;' in switchVars()).

If it is not a feature, does ST2 provide the ability to implement this as a plugin? Thanks a lot!


回答1:


Unfortunately, this is not possible, as there are no directives in the API or in color schemes for dealing with font size at that level of granularity.

However, it is possible to provide additional highlighting to your color scheme (.tmTheme file) so that function definitions stand out. It looks like you're using Monokai, so open Packages/Color Scheme - Default/Monokai.tmTheme and add the following to the end, just before the final </array>:

        <dict>
            <key>name</key>
            <string>Function definition</string>
            <key>scope</key>
            <string>meta.function</string>
            <key>settings</key>
            <dict>
                <key>background</key>
                <string>#000080</string>
            </dict>
        </dict>

This will highlight your function definition lines in a dark blue:

It also works for alternate function definition syntaxes:

Good luck!



来源:https://stackoverflow.com/questions/20414173/per-token-font-size-in-sublime-text-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!