Atom Kirby snippets

Today I switch from Sublime to Atom and discover the snippet functionality (maybe Sublime have it too)
It’s just shortcuts for bit of text you use frequently, so I made some for kirby.

you just start to entering the keyword, hit tab, and all the code is created, with possible code edit when you press tab again. Useful for long chainings or repetitive code like echo the page title.

Some example:

If you use Atom you can copy this to your snippets.cson and adapt it to your needs:

    'prefix': 'page'
    'body': 'page(\'${1:pageuid}\')->$2'
  'Field in current page':
    'prefix': 'page field'
    'body': '$page->${1:text}()->$2'
  'Field in current page with kirbytext':
    'prefix': 'ktfield'
    'body': '<?php echo $page->${1:text}()->${2:kirbytext}(); ?>'
  'Kirby thumb':
    'prefix': 'thumb'
    'body': '->thumb([\'width\' => ${2:size}, \'height\' => ${3:size}${1:, \'crop\' => true}])${4:->url()};'
  'Kirby thumb img tag ':
    'prefix': 'imgthumb'
    'body': '<img src="<?php echo \$${1:image}->thumb([\'width\' => ${3:size}, \'height\' => ${4:size}${2:, \'crop\' => true}])->url(); ?>" alt="<?php echo \$${5:image->filename()} ?>" />'
  'Page child':
    'prefix': 'children'
    'body': '$page->children()${1:->visible()}'
    'prefix': 'kirbychain'
    'body': '${1:text}()->$2'

If you have some other useful kirby snippets ideas, tell me!


I started this Kirby Snippets Plugin for Sublime Text ( ) but didn’t maintain it for some time, because I switched to Atom, too.

Maybe it’s possible to transfer that sublime-snippets to Atom. I won’t have time to do it on my own alone, but with some help of other Atom-Users, this might be a good thing.

Whoever is interested, tell me, I’ll open up a repo on GitHub and we can start working on it.

btw. whoever want’s to update that sublime-text-snippets, feel free to work on it. Just send me a message and I’ll add you as contributer to the repo or something like that.

1 Like

Great ! the snippet syntax seems quite the same, maybe we can convert it to Atom with some regexp. I will find a solution.

1 Like

I tried to convert my Espresso Snippets plugin to Atom, since I use Atom now. Maybe the json I created helps you:

Thank you, it’s easier with one file. I also found this: but haven’t tested it yet.

That looks nice, I will give it a try.

Hey @thguenther,
Would you be able to explain how to install your methods.json file ?

Hey @Thiousi,

I converted my Espresso autocomplete plugin to a json inspired by Atom Autocomplete Providers with a few regular expressions. It’s pretty extensive and covers the whole Kirby docs with a “read more” link and everything.

Since @judbd created snippets for a few functions I thought he could easily adapt my json and add everything.

I sadly never figured out how to create a autocomplete plugin for Atom that extends, suggests, sets the cursor and so on. That’s something a bit more productive than just “snippets”. I also went back to using Espresso again. The json of the Kirby docs is the most work though I suppose, so at least that’s already done :slight_smile:


Cool Idea :heart_eyes:

meh updated atom and now kirby autocomplete is not working anymore :frowning: too sad, it helped out quite frequently.