macos Textmate 选项卡和取消选项卡选定的块

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2944400/
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-10-21 06:58:28  来源:igfitidea点击:

Textmate tab and de-tab selected block

macostextmate

提问by Derek Organ

Recently switched to Textmate on Mac for coding. On PC when ever I want to tab in or out a block of code I just highlight and press tab or shift+tab to move it in our out. It's very useful when you are adding an extra loop or conditional statement to a block of code to keep everything tidy and neatly indented.

最近在 Mac 上切换到 Textmate 进行编码。在 PC 上,当我想插入或移出代码块时,我只需突出显示并按 Tab 或 shift+tab 即可将其移出。当您向代码块添加额外的循环或条件语句以保持所有内容整洁并缩进时,它非常有用。

On Textmate however when I try this it just replaces my selected text with a tab. So is there a way to do tab and de-tab lines of code in textmate?

但是,在 Textmate 上,当我尝试此操作时,它只是用选项卡替换了我选择的文本。那么有没有办法在 textmate 中执行 tab 和 de-tab 代码行?

回答by David Antaramian

Indent: Alt+Tab

缩进:Alt+Tab

Un-Indent: Shift+Alt+Tab

取消缩进:Shift+Alt+Tab

回答by Josh

the hotkey is command-left bracket to move left and command-right bracket to move right (the buttons next to 'p')

热键是 command-left 括号向左移动和 command-right 括号向右移动('p'旁边的按钮)

heres a link to more hotkeys and such http://projects.serenity.de/textmate/tutorials/basics/

这是指向更多热键的链接,例如 http://projects.serenity.de/textmate/tutorials/basics/

回答by Graham P Heath

You canuse Shift+Tab to decrease indent; You just need to make and assign a macro. You can reuse this technique to accomplish a great many things.

可以使用 Shift+Tab 来减少缩进;您只需要制作和分配一个宏。您可以重复使用这种技术来完成很多事情。

  1. Enter some text, and intend them, this is mostly for feedback.

  2. Click the Record Macro Button

  1. 输入一些文本,并打算它们,这主要是为了反馈。

  2. 单击录制宏按钮

Click the Record Macro Button

单击录制宏按钮

  1. Use ?+?+?(aka; Shift+ Option+ Tab) to decrease the indentation.

  2. Click the record button to stop recording the macro.

  3. Use the Editmenu or ?+?+Mto save your macro;

    Edit ->Macros ->Save Macro

  4. Saving will prompt you to create a new bundle*, or add your macro to an existing bundle.

  5. Add a Key Equivalentby clicking in the field and pressing ?+?

  6. Your bundle-macro should look like the one below, simply Save and you're done! TextMate will now decrease indent on ?+?

  1. 使用?+ ?+ ?(aka; Shift+ Option+ Tab) 来减少缩进。

  2. 单击录制按钮停止录制宏。

  3. 使用Edit菜单或?+ ?+ M,以节省您的宏;

    编辑 ->宏 ->保存宏

  4. 保存将提示您创建新包*,或将宏添加到现有包中。

  5. 添加Key Equivalent通过点击字段并按下 ?+?

  6. 您的捆绑宏应该如下所示,只需保存即可!TextMate 现在将减少?+ 上的缩进?

Completed Macro

已完成的宏

*: (as noted by u/PatrickT) Sadly the create new bundle functionality has not yet been implemented, and you must choose to add to an existing bundle. You can still create a bundle via Bundles -> Edit Bundles then Command + N.

*:(如 u/PatrickT 所述)遗憾的是,尚未实现创建新包功能,您必须选择添加到现有包中。您仍然可以通过 Bundles -> Edit Bundles 然后 Command + N 创建一个 bundle。

回答by Alexander Klimetschek

As an alternative, you can change the keybindings, see http://blog.macromates.com/2005/key-bindings-for-switchers/

作为替代方案,您可以更改键绑定,请参阅http://blog.macromates.com/2005/key-bindings-for-switchers/

Here is what I did:

这是我所做的:

  • Install http://www.cocoabits.com/KeyBindingsEditor/
  • Go to File -> Open -> User Key Bindings, this will create/edit ~/Libary/KeyBindings/DefaultKeyBinding.dict
  • Add a binding, for the action enter shiftRight:(indent) manually (this is a TextMate specific action and not in the pre-populated actions list)
  • Choose a shortcut, I used cmd+alt+right
  • Do the same for the action shiftLeft:(un-indent, I used cmd+alt+left)
  • Save and then restart TextMate
  • 安装http://www.cocoabits.com/KeyBindingsEditor/
  • 转到File -> Open -> User Key Bindings,这将创建/编辑~/Libary/KeyBindings/DefaultKeyBinding.dict
  • 添加绑定,为操作输入shiftRight:(indent) 手动(这是 TextMate 特定操作,不在预填充的操作列表中)
  • 选择快捷方式,我用的是cmd+alt+right
  • 对操作shiftLeft执行相同操作:(取消缩进,我使用cmd+alt+left
  • 保存然后重新启动 TextMate

I used a shortcut with arrow keys as my right hand is already on the arrow keys when I am selecting multiple lines, so this is a good fit.

我使用了带有箭头键的快捷方式,因为当我选择多行时,我的右手已经在箭头键上,所以这是一个很好的选择。

The reason why I did it was because I have a german keyboard and alt+tab/alt+shift+tabdon't work for me since I am using http://manytricks.com/witch/for app-switching using these exact shortcuts.

我这样做的原因是因为我有一个德语键盘和alt+tab/ alt+shift+tab对我不起作用,因为我使用http://manytricks.com/witch/使用这些精确的应用程序切换捷径。

EDIT:cmd+alt+left/rightdon't workwhen you have multiple tabs open, as they are used for navigate to next or previous tab in TextMate... seems this cannot be changed or overridden (I tried Setting Shortcut Keys in Textmate). Looking for an alternative shortcut now.

编辑:当您打开多个选项卡时,cmd+alt+left/right不起作用,因为它们用于导航到 TextMate 中的下一个或上一个选项卡...似乎无法更改或覆盖(我尝试在文友)。现在正在寻找替代的快捷方式。