Create shortcut


I would like to how can i create keyboard shorcut in atom like Sublime text 3 ?
I want to create the same Sublime shortcut as follows:

** { “keys”: [“ctrl+u”], “command”: “upper_case” },**
** { “keys”: [“ctrl+l”], “command”: “lower_case” },**


The Flight Manual has a section on keybindings.


I do this in keymap.cson :slight_smile:
‘ctrl+u’: 'editor:uppercase’
Is that correct ? If so, it does not work.


If you look at the Command Palette (ctrl-shift-p) or Settings -> Keybindings, you can observe that the command is named editor:upper-case.


Many thanks,
It works now.
Could you tell me where i could find tutorials expaining Atom deeply ?
Because, i want to know Atom as well i know Sublime Text 'specially snippets".
Best regards


Deeply? Look at the API, and the source code behind the API. The flight manual walks you through several examples of making a package. Other packages are also a good guide. For anything you’re still not sure about, there is this forum or slack.

If there is something in particular, I’ll do my best to help. I know a decent amount about snippets and autocomplete.


Deeply, i would say in depth.
About snippets, in Sublime i have created this one:


]]> cl The same in atom: '.text.html.basic': 'div class': 'prefix': 'dc' 'body': """
""" In sublime i grab dc+tab, it gives me exactly what i want, but in Atom i get I cannot find what to do. If you can help me. Regards


Please wrap all code in ```, like as follows

<write it here>

This ensures whitespace is preserved and some other important things, so I can actually understand what you’ve just pasted above.


In any case, I think this is what you are asking for

    'prefix': 'dc'
    'body': '\n\t\t$0\n'

Pasting that into your snippets.cson file will make a snippet with prefix dc that will expand to a bunch of new lines and tabs (the equivalent length in spaces will be used if soft tabs is your setting). The cursor will be placed after the tabs on the second line.

To activate the snippet, just press tab after typing the prefix.



<div class="$1">
</div><!-- .${1/\*//} -->



   'div class':
      'prefix': 'dc'
      'body': """
      <div class="${1}">\n\t\t${0}\n</div><!-- .${1} -->


That Atom snippet works fine for me. What were you expecting as a result?


In my editor settings Atom Soft Tabs is aciivated. Is that correct ?
If not, what i have to set in Atom ?


I meant that there is a setting at the bottom of the Editor section called Tab Type. This allows you to use ‘soft tabs’ which means instead of placing an actual tab character when you press tab, it puts in the equivalent length of spaces (according to the tab length setting)


But, in ‘Tab Type’ there are 3 options (auto, soft, hard). Wich iis the good one, i’ve tried ech one, same resutl.
The fact i have replace Sublime by Atom, is that Sublime has a bug (each() function is depecated when using a PHP version >= 7.2.0), or the version i use is PHP-7.2.2.
I don’t find a good tuorial for Atom, the snippets example show only a ‘.souece.js’, i try it and it works fine.
I want that it works for a PHP an HTML source.


The result i expect is “dc+tab”

<div class="test">
</div><!-- .test -->

exactly what i do in Sublime, that’it


It may behave the same, but there is a difference. If you turn on invisibles, you will see that hard tabs look like a guillemet, while spaces are dots.

Hard tabs are literal tab characters (the \t kind). Soft tabs are just spaces, so they appear as such when invisibles are turned on. Auto decides which to use based on what’s already been used in the file. There is yet another setting in Atom though, called Atomic soft tabs which is causing the soft-tab spaces to behave like real tabs when moving the cursor and such.

The best one to pick depends. I find most people use spaces, so I stick to soft tabs. TO be consistent with other people, you may want auto. I strongly advise against hard tabs.

Like this? To get the expansion, I pressed tab. If this isn’t what you are getting, I’m going to need more description about what’s happening for you.



That’s excactly what i want, but it must work in php html source.
How to do this in Atom ?


Just add the scope (comma separated). So like the following

'.text.html.basic, .php':
   'div class':
      'prefix': 'dc'
      'body': """
      <div class="${1}">\n\t\t${0}\n</div><!-- .${1} -->

Scope syntax is kind of mentioned in the flight manual, but it’s pretty bad and uninformative. I found the best way of learning what you can do with it is looking at the first-mate specs. For this purpose though, you don’t need to worry about it. It’s only when you want more complicated behaviour that is is necessary to worry about it.


Thanks, it works fine now in a php file like index.php.
I have modified for that in keymap.cson as followws:

#'atom-text-editor[data-grammar="text html php"]:not([mini])':
#   'tab': 'emmet:expand-abbreviation-with-tab'

But now, the html tags don’t work, example:

h1.text-center + tab

must give

<h1 class="text-center"></h1>

In an html file, it works, but not in a php file. I want that it works the same in html or php file.
dc+tab don’t work in html file.
Sorry for the inconvenience, but your help is welcome.
Thanks very much.


That is commented out.