Textmate tab and de-tab selected block

梦想与她 提交于 2019-11-30 11:21:35

问题


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.

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?


回答1:


Indent: Alt+Tab

Un-Indent: Shift+Alt+Tab




回答2:


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

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




回答3:


As an alternative, you can change the keybindings, see 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

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+tab don't work for me since I am using http://manytricks.com/witch/ for app-switching using these exact shortcuts.

EDIT: cmd+alt+left/right don't work when 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.




回答4:


You can use 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.

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

  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 Edit menu or ++M to save your macro;

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

  5. Add a Key Equivalent by 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 +

*: (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.



来源:https://stackoverflow.com/questions/2944400/textmate-tab-and-de-tab-selected-block

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!