typescript 将 .ts 语言文件添加到 Sublime Text 以支持额外的语法着色

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12785583/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 16:13:51  来源:igfitidea点击:

Add .ts language files to Sublime Text to support additional syntax coloring

sublimetext2typescript

提问by Nick Heiner

I'm trying to add Typescript syntax highlighting support, which is providedby MSFT. However, I don't know what to do with that downloaded .zip to make Sublime recognize .tsfiles. I tried adding it to Installed Packages/Typescript, or just Installed Packages, but that hasn't worked. (I also tried extracting the .tmlanguagefile and putting that in Installed Packages/Typescript.

我正在尝试添加MSFT提供的Typescript 语法高亮支持。但是,我不知道如何处理下载的 .zip 以使 Sublime 识别.ts文件。我尝试将它添加到Installed Packages/Typescript,或者只是Installed Packages,但这没有用。(我也尝试提取.tmlanguage文件并将其放入Installed Packages/Typescript.

What is the right way to do this? (I'm on Mac OS X 10.8 with Sublime text 2.0.1.)

这样做的正确方法是什么?(我在 Mac OS X 10.8 上使用 Sublime text 2.0.1。)

回答by Claudijo

To add TypeScript syntax highlighting support to Sublime Text on Mac:

在 Mac 上为 Sublime Text 添加 TypeScript 语法高亮支持:

  1. Unzip the downloaded file. It contains a file named typescript.tmlanguage
  2. Create a subfolder in your sublime Package folder called TypeScript. (The path to the Packages folder for Sublime Text 2 on Mac is:
    /Users/{user}/Library/Application Support/Sublime Text 2/Packages)
  3. Drop typescript.tmlanguage into your newly created TypeScript folder.
  1. 解压下载的文件。它包含一个名为 typescript.tmlanguage 的文件
  2. 在名为 TypeScript 的 sublime Package 文件夹中创建一个子文件夹。(Mac 上 Sublime Text 2 的 Packages 文件夹的路径是:
    /Users/{user}/Library/Application Support/Sublime Text 2/Packages)
  3. 将 typescript.tmlanguage 放入新创建的 TypeScript 文件夹中。

回答by Katana24

For me none of these ways actually worked as they should have.

对我来说,这些方法都没有真正发挥应有的作用。

Instead I had to hit (On a Mac and using Sublime Text 2) Cmd+Shift+Pand then type Package Control:Install Packageand then hit enter. You may see it load in the bottom left.

相反,我必须点击(在 Mac 上并使用 Sublime Text 2)Cmd+Shift+P,然后输入Package Control:Install Package然后点击 Enter。您可能会在左下角看到它正在加载。

From there is was a matter of searching for the script (in my case TypeScript), selecting it and hitting enter.

从这里开始是搜索脚本(在我的情况下为 TypeScript),选择它并按 Enter 键的问题。

回答by Murat Sutunc

If you go to the Sublime Textwebsite, they have instructions there. To make it work in Windows you have to create the Typescript folder at:

如果你去Sublime Text网站,那里有说明。要使其在 Windows 中工作,您必须在以下位置创建 Typescript 文件夹:

C:\Users\\AppData\Roaming\Sublime Text 2\Packages\TypeScript

C:\Users\\AppData\Roaming\Sublime Text 2\Packages\TypeScript

and copy the typescript.tmlanguage file inside that folder. Claudijo provides an equivalent answer for Mac OS X users.

并复制该文件夹中的 typescript.tmlanguage 文件。Cludijo为 Mac OS X 用户提供了一个等效的答案