Home Download Buy Blog Forum Support

snippet problems

snippet problems

Postby mark4 on Sat Dec 15, 2012 7:41 pm

I have a snippet i defined for my forth programming as follows...

Code: Select all
<snippet>
    <content><![CDATA[
: ${1} ${2}( ${3} --- ${4} )
  ${5} ;]]></content>
    <!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
    <tabTrigger>:</tabTrigger>
    <!-- Optional: Set a scope to limit where the snippet will trigger -->
    <!-- <scope>source.python</scope> -->
</snippet>


if i use this and get to tab point 5 in order to activate a second snippet i have (say for an IF statemetn) i have to hit escape. it would be nice if i could didnt have to do this. But lets say i hit escape at point 5 and then activate my if snippet the indentations are messed up

Code: Select all
: foo       ( x y z --- bar )
  if
    tab point here
  then ;   <-- **


** the "then" is pasted in with an extra space and is thus indented one space further in than the if. Here is my IF snippet

Code: Select all
<snippet>
    <content><![CDATA[
if
  ${1}
then]]></content>
    <!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
    <tabTrigger>if</tabTrigger>
    <!-- Optional: Set a scope to limit where the snippet will trigger -->
    <!-- <scope>source.python</scope> -->
</snippet>


edit: p.s. it would be nice if i could have a tab point called $(0) to define the final tab point in a snippet :)
edit: MAYBE if i just TRY something before suggesting it as an idea i might discover that someone far smarter than I am already thought of it :)
mark4
 
Posts: 98
Joined: Sat Feb 11, 2012 3:33 am

Re: snippet problems

Postby agibsonsw on Sun Dec 16, 2012 9:53 am

You can use $0 to signify the end-point for snippets, but there is nothing special about it AFAIK - it's just the last tab-position.

The extra space is before the ; in your first snippet so I suppose you could delete it if you don't need it.

I use the following set of key-bindings so that I can use Ctrl-Alt-Right or Ctrl-Alt-Left to insert one snippet within another (or cycle through them).

Code: Select all
   { "keys": ["ctrl+alt+right"], "command": "insert_best_completion", "args": {"default": "", "exact": true} },
   { "keys": ["ctrl+alt+right"], "command": "insert_best_completion", "args": {"default": "", "exact": false},
      "context":
      [
         { "key": "setting.tab_completion", "operator": "equal", "operand": true }
      ]
   },
   { "keys": ["ctrl+alt+right"], "command": "replace_completion_with_next_completion", "context":
      [
         { "key": "last_command", "operator": "equal", "operand": "insert_best_completion" },
         { "key": "setting.tab_completion", "operator": "equal", "operand": true }
      ]
   },
   { "keys": ["ctrl+alt+left"], "command": "replace_completion_with_prev_completion", "context":
      [
         { "key": "last_command", "operator": "equal", "operand": "insert_best_completion" },
         { "key": "setting.tab_completion", "operator": "equal", "operand": true }
      ]
   }
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm


Return to Technical Support

Who is online

Users browsing this forum: Exabot [Bot], Google [Bot] and 39 guests