Search code examples
textmatecode-snippets

textmate snippets and tabs


i'm using snippets in textmate a lot -- especially for adding API documentation to my sources.

you can define placeholders in a snippet and you can use TAB / SHIFT+TAB to jump between those placeholders.

my question is:

is it still somehow possible to insert a tab at the current cursor position inside a placeholder position without breaking snippets' TAB / SHIFT+TAB functionality?

thanks a lot!


Solution

  • i think i found a "solution" for this:

    i added a new command with the following settings:

    save:             nothing
    command(s):       printf "%$(($TM_TAB_SIZE - $TM_LINE_INDEX % $TM_TAB_SIZE))s"
    input:            none
    output:           insert as text
    
    activation:       key equivalent - CTRL + SPACE
    scope selector:   comment.block
    

    the key equivalent could also be CTRL + TAB or so, but the TAB has already assigned many functionality. works like a charm for me.

    i am using spaces instead of tabs ... so if someone prefers tabs, the solutions needs to be adjusted.