【问题标题】:How do I insert a snippet of text using a keyboard shortcut in Sublime Text?如何在 Sublime Text 中使用键盘快捷键插入一段文本?
【发布时间】:2014-06-12 14:20:49
【问题描述】:

如何设置插入 console.log() 的快捷方式并将其包裹在 Sublime Text 中的当前选择中而不安装任何插件或额外的第三方内容?

【问题讨论】:

  • 问题本身(没有答案)不太清楚你的意思。如果您改写为询问如何使用 Sublime Text 中的键盘快捷键插入文本的 sn-p(以 console.log() 为例),它可能对每个人都更有用。 =)
  • 我在编辑方面也很擅长。如果您觉得这不是改进,请随时更改。

标签: sublimetext2 sublimetext sublimetext3


【解决方案1】:

所以我找到了答案。以为我会在这里为其他人添加它:

转到Sublime Text 2 > Preferences > Key Bindings - User 并将此 JSON 添加到文件中:

[
    { "keys": ["alt+d"],
      "command": "insert_snippet",
      "args": {
        "contents": "console.log(${1:}$SELECTION);${0}"
      }
    }
]

在按下alt+d时在当前光标位置插入console.log()

参考:https://gist.github.com/harthur/2951063

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-08-31
    • 2019-08-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-23
    • 2014-12-27
    相关资源
    最近更新 更多