On 05.12.2008, at 07:07, Abhimanyu Lad wrote:
""" $TM_FILENAME ${1:args} """ if len(argv) != <some regex that counts number of
words in $1>: exit(1)
$0
Depending on the number of words that I enter for args, I want the appropriate number to be inserted in front of "if len(argv) != ...".
Ad hoc I have no solution by using a single regexp but a quick&dirty solution would be this snippet:
""" $TM_FILENAME ${1:args} """
if len(argv) != ${2:ruby -e 'p "$1".strip.split(/\S+/).size'}: exit(1) $0
invoke it, type something for args, press TAB, press CTRL+OPT+R (it executes the selection in bash and replaces the selection by the result)
Or write a tmcommand which counts the words in selection and replaces the selection with that number. then: """ $TM_FILENAME ${1:args} """
if len(argv) != ${2:$1}: exit(1) $0
type args, press TAB, invoke that tmcommand
--Hans