textmate 主题_更漂亮的TextMate

textmate 主题

textmate 主题

Prettier is a code formatter, great for following consistent coding conventions with 0 effort. Here's how to add it to TextMate, my text editor of choice.

Prettier是一种代码格式化程序,非常适合以0的努力遵循一致的编码约定。 这是将其添加到我选择的文本编辑器TextMate中的方法。

安装更漂亮 (Install Prettier)

Globally, so you take advantage of it in any old directory.

在全球范围内,因此您可以在任何旧目录中使用它。

npm install --global prettier

If that doesn't work, you probably need to install Node first. So off to the download page you go and then back to the command above.

如果这不起作用,则可能需要先安装Node。 因此,转到下载页面,然后返回到上面的命令。

设定档 (Config)

This is the one I use, I stole it from React and simplified:

这是我使用的,我从React那里偷了出来并简化了:

'use strict';

module.exports = {
  bracketSpacing: false,
  singleQuote: true,
  jsxBracketSameLine: true,
  printWidth: 80,
  trailingComma: 'all',
};

Save this somewhere in your path, e.g. your home directory:

将其保存在路径中的某个位置,例如您的主目录:

~/.prettierrc.js

TextMate (TextMate)

Go to menu "Bundles", then "Edit Bundles", then "CSS", then "Menu Actions".

进入菜单“捆绑包”,然后进入“编辑捆绑包”,然后进入“ CSS”,然后进入“菜单操作”。

(Doesn't have to be CSS, Prettier formats a lot of things. I just happen to be working on a CSS file)

(不必是CSS,Prettier会格式化很多东西。我只是碰巧正在处理CSS文件)

Then menu "File", then "New", then "Command" from the dropdown.

然后从下拉菜单中依次选择“文件”,“新建”和“命令”。

Then fill out the stuff as you see on the screenshot:

然后填写您在屏幕截图中看到的内容:

I choose CTRL+Q shortcut as it already exists as "Format CSS" command, which I'm essentially replacing.

我选择CTRL + Q快捷键,因为它已作为“格式化CSS”命令存在,而我实际上是在替换它。

The code you need is:

您需要的代码是:

#!/usr/bin/env ruby18
require ENV['TM_SUPPORT_PATH'] + '/lib/textmate'
error = `/usr/local/bin/prettier --write "$TM_FILEPATH"`
puts error

You also need to have the path to node and to prettier (likely the same) in your TextMate path preferences (menu TextMate / Preferences / Variables / PATH). To tell where node is, type which node.

您还需要在TextMate路径首选项(菜单TextMate / Preferences / Variables / PATH)中具有指向nodeprettier (可能相同)的路径。 要确定节点在哪里,请键入which node

And this is it - save, and start using!

就是这样-保存并开始使用!

跑步 (Running)

Open an ugly file:

打开一个丑陋的文件:

Press CTRL+Q (or your selected shortcut) and then all is pretty:

按CTRL + Q(或您选择的快捷方式),然后一切都很漂亮:

Oooor, open a file with an error:

糟糕,打开错误文件:

... and see the error, without the need to test in the browser and pull hair:

...并看到错误,而无需在浏览器中进行测试并拉头发:

再见! (Bye!)

So pretty! And don't forget, Prettier formats JS, JSON and what not. When in doubt, just try it!

好漂亮! 而且不要忘记,Prettier可以格式化JS,JSON和其他格式。 如有疑问,请尝试!

Ah, and don't forget Stylelint in your TextMate too.

嗯,也不要忘记TextMate中的Stylelint

Tell your friends about this post on Facebook and Twitter

FacebookTwitter上告诉您的朋友有关此帖子的信息

翻译自: https://www.phpied.com/prettier-in-textmate/

textmate 主题

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值