Atom snippets for linspace etc

I find it tedious to use the new range constructor, especially to construct logarithmically spaced ranges.
exp10.(range(-1, stop=1, length=10))
I therefore created atom snippets to write them out for me. Now I only have to start typing linspace or logspace as before and insert the snippet with a press on . I thought my snippets below might be of use for others as well. To use them, place the code below in your snippets.cson (Ctrl-shift-P to open command palette and search for “open your snippets” to open snippets.cson).

'.source.julia':

  'pkgdir':
    'prefix': 'pkgdir'
    'body': 'joinpath(dirname(pathof($1)), "$2")$3'

  'logspace':
    'prefix': 'logspace'
    'body': 'exp10.(range($1, stop=$2, length=$3))$4'

  'linspace':
    'prefix': 'linspace'
    'body': 'range($1, stop=$2, length=$3)$4'

  'eye':
    'prefix': 'eye'
    'body': 'Matrix{Float64}(I, $1, $1)$2'

  'TODO':
    'prefix': 'todo'
    'body': '# TODO: $1'

  'iter':
    'prefix': 'iter'
    'body': 'function Base.iterate($1::$2, state=$3)\nstate == length($4) && return nothing\n ($5,state+1)\nend\nBase.length($1::$2)\n'

  'esc':
    'prefix': 'esc'
    'body': '\$(esc($1))$2'
3 Likes