热键以分号结尾并跳至Sublime Text 2中的新行 [英] Hotkey to end the line with a semicolon and jump to a new line in Sublime Text 2
问题描述
我正在尝试找出工作中的热键.我刚得到这份工作,这是我一生中第一次或多或少使用Mac.
I'm trying to figure out a hotkey at work. I just got this job and I am using a Mac for more or less the first time in my life.
回到我的笔记本电脑上,使用Eclipse时,我似乎还记得有一个热键可以同时使用:
Back home on my Laptop, when using Eclipse, I seem to remember there being a single hotkey which would both:
- 在当前行的结束中添加
;
(无论插入符号在所述行中的何处) - 将光标放在新行的开头,其缩进级别与我刚刚在其中添加分号的行的缩进级别
- Add a
;
to the end of my current line (no matter where the caret was within said line) - Place my cursor at the beginning of a new line, with the same indentation level as the line I had just added a semicolon to
有人知道这是否是Eclipse特定的热键,还是知道在Sublime Text 2中复制该热键的方法?
Does anybody know if this was an Eclipse-specific hotkey, or know of a way to replicate said hotkey in Sublime Text 2?
推荐答案
为此的最佳解决方案是在Sublime Text上录制宏,然后将其分配给键盘快捷键.请按照下列步骤操作:
Best solution for this is recording a macro on Sublime Text and then assigning it to a keyboard shortcut. Follow these steps:
- 创建诸如alert('hello')之类的行并将光标保持在右侧 在字母"o"之后.
- 然后转到工具>录制宏开始录制.
- 按 Command + →转到行尾.
- 按; 并按 Enter
- 转到工具>停止录制宏 ,停止录制宏
- 您现在可以通过工具>播放宏(可选) 来测试宏
- 通过转到工具>保存宏(例如:EndOfLine.sublime-macro)来保存宏
-
通过在您的方括号之间添加快捷方式来创建快捷方式 在偏好设置">按键绑定-用户文件"中
- Create a line such as alert('hello') and leave the cursor right after letter 'o'.
- Then go to Tools > Record a Macro to start recording.
- Press Command+→ to go to the end of line.
- Press ; and hit Enter
- Stop recording the macro by going to Tools > Stop Recording Macro
- You can now test your macro by Tools > Playback Macro (optional)
- Save your macro by going to Tools > Save Macro (ex: EndOfLine.sublime-macro)
Create a shortcut by adding this between the square brackets in your in your Preferences > Key Bindings - User file:
{
"keys": ["super+;"], "command": "run_macro_file", "args": {"file": "Packages/User/EndOfLine.sublime-macro"}
}
祝您编程愉快!
这篇关于热键以分号结尾并跳至Sublime Text 2中的新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!