Fuzzy Syntax auto compelete


#1

Hi guys, not really sure how to descirbe this. but one of the things I like in other editors (ie sublime) is that when I work with css/sass I can type things like “bgi” and the edtior auto-complete it to “background-image”. is there anything like that for Atom?


#2

You can use the language-css-plus package, which includes quite a few of these as snippets. You can also define your own snippets if there’s any others you want.


#3

To define your own you can paste something like this into your snippets.cson (File -> Open Your Snippets):

'.source.css':
  'Background Image':
    'prefix': 'bgi'
    'body': 'background-image $1'

You can also make more complex snippets by including linebreaks (\n), tabs (\t) etc in the body. Using the $ and incrementing it you can control where in the snippet you can tab to. Illustrative example (probably not a very useful snippet in practise):

'.source.css':
  'Margin and Padding':
    'prefix': 'marpad'
    'body': 'padding: $1px;\nmargin: $2px;\n$3'